Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema Dump command #152

Closed
tpow opened this issue Aug 22, 2020 · 0 comments
Closed

Schema Dump command #152

tpow opened this issue Aug 22, 2020 · 0 comments
Labels
feature request A feature that does not yet exist but will be a good addition to the library medium These issues are geared for people who have contributed to the project before

Comments

@tpow
Copy link

tpow commented Aug 22, 2020

It would be helpful to have a command that can generate a dump of the current database schema after the latest migrations. Ideally the format of the file will be similar to that of the database migration files and can be used both to review the schema of the database as well as potentially used to create a new version of the database without needing to run through each migration again (with a schema load command, perhaps). Reapplying all migrations can be fragile and time consuming as a project develops over time. Having a schema file lets you remove old migrations after they have been applied without losing the information in your project.

Ideally this file would be automatically regenerated every time you run a migration. Being able to generate it on demand would be a start.

I am proposing that the command would create a schema.py, similar to Ruby on Rail's schema.rb. The Ruby Guide explains Schema Dumping and its usefulness as well as how it relates to migrations. It says this about the schema file:

If you look at this file you'll find that it looks an awful lot like one very big migration. In many ways this is exactly what it is. This file is created by inspecting the database and expressing its structure using create_table, add_index, and so on.

Although the database itself is obviously the true source of the schema (which is why Rails also allows for dumping in a DB specific format), having the schema in the ORM format lets you apply it across database engines and shortcut lengthy migrations.

@josephmancuso josephmancuso added the feature request A feature that does not yet exist but will be a good addition to the library label Sep 21, 2020
@josephmancuso josephmancuso added the medium These issues are geared for people who have contributed to the project before label Dec 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A feature that does not yet exist but will be a good addition to the library medium These issues are geared for people who have contributed to the project before
Projects
No open projects
Development

No branches or pull requests

2 participants