Package: simple_migrator
Simple MigratorA simple tool written in python to run simple migrations.Basic Usage0. InstallationOn Macos Installbrewinstall--caskmysql-connector-pythonpipinstallsimple_migrator1. Setupsimple_migratorsetup{DATABASE_URL}Result:-File_pathmigrations/.config
Checkingifmigrationtableexists
Migrationtablenotexists
CreatingTable__migrations_table__2. Createsimple_migratorcreate{MIGRATION_NAME}Result:-Migration1704095392331687000_migration_uoi.sqlcreatedatmigrations/1704095392331687000_migration_uoi.sql3. Applyi. There are two ways to apply the migration. One way is to apply all the latest pending migrations.simple_migratorupResult:-Goingtorunthefollowingmigrations:1704096783004737000_migration_3.sql
Migraiton1704096783004737000_migration_3.sql:COMPLETED
ThefollowingmigrationrunnedSuccessfully:['1704096783004737000_migration_3.sql']ii. Another way to do this is to give the files name to the up command.Note that this method will rerun the given migrations file.simple_migratorup--f1703509439.048595_tempResult:-Goingtorunthefollowingmigrations:1704097419937590000_migration_0.sql
Migraiton1704097419937590000_migration_0.sql:COMPLETED
ThefollowingmigrationrunnedSuccessfully:['1704097419937590000_migration_0.sql']3. Rollbacki. Similar to "up" migration there are two ways to do thissimple_migratordownResult:-Goingtorunthefollowingmigrations:['1704097461646876000_migration_1.sql']RollbackMigraiton1704097461646876000_migration_1.sqlcompleted
Allmigrationrollbacksuccessfully.ii. Another way to do this is to give the files name to the up command.Note that this method will rollback every migration no matter if they were applied or not.simple_migratordown--files1703509439.048595_tempResult:-Goingtorunthefollowingmigrations:['1704097419937590000_migration_0.sql']RollbackMigraiton1704097419937590000_migration_0.sqlcompletedAllmigrationrollbacksuccessfully.4. Listi.  List AllThis will list all the migrations present.simple_migratorlistallResult:-NameStatusApplied At1704097419937590000_migration_0.sqlMigrationStatus.PENDING2024-01-01 14:03:14.2254021704097461646876000_migration_1.sqlMigrationStatus.APPLIED2024-01-01 14:00:21.011784ii. List All AppliedThis will list all the migrations present.simple_migratorlistappliedNameStatusApplied At1704097461646876000_migration_1.sqlMigrationStatus.APPLIED2024-01-01 14:00:21.011784iii. List All AppliedThis will list the last applied migrations.simple_migratorlistlast-appliedNameStatusApplied At1704097461646876000_migration_1.sqlMigrationStatus.APPLIED2024-01-01 14:00:21.011784iv. List PendingThis will list the all the pending migrations.simple_migratorlistpendingNameStatusApplied At1704097419937590000_migration_0.sqlMigrationStatus.PENDING2024-01-01 14:03:14.2254025. UpdateThis command is used when you want to update the migration status of certain migrations. You can set different migrations status with --files file_name_1 --files file_name_2 and --status can be set to pending|applied|failedResult:-Goingtoupdatethefollowingmigrations:['1704097461646876000_migration_1.sql']tostatuspending
Migrations:['1704097461646876000_migration_1.sql']updatedtostatuspending6. ScyncWhen the database and the migration files are not in scynced. Use this command to scync it.poetryrunpythonsimple_migrator/migrator.pyscync--status appliedResult:-1704097461646876000_migration_1.sql
ScyncingcompletedVisit:GithubPyPiWebsiteTDOD:Make it so that the project does not reset when the setup is called twice.(There must be a better way).Add tests to ensure that it works.Add tests with other databases to ensure that it works.Add a decorator so that we can check if setup is correctly done and exists gracefully.Make sql errors more visible.Exist gracefully when database name is suppied properly.