-
-
Notifications
You must be signed in to change notification settings - Fork 521
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
CLI command to generate a new migration #656
Conversation
This subcommend will create a new, empty migration.
This crate will allow me to fetch the current date and time required for generating the migration filename.
Allows me to parse the lib.rs file containing the migrator logic.
This modifies the existing migator file, adding a module declaration for the newly generated migration.
This completes updating the migrator file with the new migration information.
This avoids conflicts with the other tests.
Thanks a lot. It definitely looks promising |
@billy1624 thoughts? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @viktorbahr, sorry for the delay! Thank you for the contributions!
No worries @billy1624 🖖 - thanks for your feedback. |
As suggested by @billy1624 in the review of #656.
As suggested by @billy1624 in the review of #656.
Two good points, included the changes suggested by you, please re-review @billy1624 . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! @viktorbahr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you
* Custom join condition (SeaQL/sea-orm#793) * Migration does not depend on entity crate * Define integer enum with repr[x] syntax * Document datatype mappings (SeaQL/sea-orm#772) * Cursor pagination (SeaQL/sea-orm#754, SeaQL/sea-orm#822) * (de)serialize custom JSON types (SeaQL/sea-orm#794) * Generate new migration file (SeaQL/sea-orm#656) * Skip generating entity file for specific tables (SeaQL/sea-orm#837) * Generate entity with date time crate option (SeaQL/sea-orm#724) * Drop `SelectTwoMany::one()` method (SeaQL/sea-orm#813) * Datatype mappings of primitives (SeaQL/sea-orm#850, SeaQL/sea-schema#75) * Join with table alias (SeaQL/sea-orm#852) * SQLx logging level (SeaQL/sea-orm#800) * Insert with on conflict (SeaQL/sea-orm#791) * Migrate generate should take file name as argument instead of option (SeaQL/sea-orm#870) * Upgrade docusaurus to 2.0.0-beta.22 * What's new in SeaORM 0.9.0 * Move migration section forward * Rename "Generating Database Schema" section to "Generating SeaQuery Statement" * Fix broken links * Edit * Edit * Edit * Edit Co-authored-by: Chris Tsang <[email protected]>
Adds
This PR adds a new subcommand to the SeaORM CLI that lets user create a new migration. This simplifies the migration process, new migrations no longer need to be added manually.
Example Usage:
sea migrate generate name
mYYYYMMDD_HHMMSS_name
)sea-orm/sea-orm-cli/template/migration/m20220101_000001_create_table.rs
MIGRATION_DIR
argument, similar to the othersea migrate
subcommandsMIGRATION_DIR/src/lib.rs
) to include the new migrationChanges
command.rs
chrono
crate for timestamp generationregex
crate for extracting information from the migrator filePossible Improvements
The following aspects of this PR could IMO be improved:
Run sea migration init first..
)