Generate the initial migration for an entity from its model definition
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 9.9k
- Forks
- 735
- Avg merge
- 6h 36m
- Merged PRs (30d)
- 8
Description
Motivation
Creating an initial migration for a model can be quite tedious, especially if the model is complex. It would save a lot of time if the initial migration to create the table could be generated from the model definition.
Proposed Solutions
Expand on the functionality of sea-orm-cli. Arguably create_table_from_entity already does the majority of the legwork in terms of creating the TableCreateStatement. The only thing that would need doing is dumping the generated code into a migrations file.
Current Workarounds
- Convert the generated
TableCreateStatementinto a SQL string for the chosen backend. - Convert the SQL string into a StatementBuilder (can be done by playing around with the StatementBuilder trait and
Statement::from_sql_and_values. - Use
exec_stmt()to run this SQL.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading sea-orm-cli and the Schema::create_table_from_entity API linked in the issue to understand how the TableCreateStatement is produced. The feature is done when the CLI can generate migration-file code from an entity model definition, with the generated table creation statement represented in the migration rather than only executed as SQL.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, sql
- Domain
- cli, databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100