rubenv / sql-migrate

SQL schema migration tool for Go.
MIT License
3.24k stars 280 forks source link

Support subfolder in FileSource migration #127

Closed gemscng closed 5 years ago

gemscng commented 5 years ago

Support subfolder so that we are allowed to organize the migration in folders

rubenv commented 5 years ago

Any particular reason why you'd want to put migrations in subfolders?

gemscng commented 5 years ago

@rubenv

rubenv commented 5 years ago
  • I have another use case, which we need to separate Foreign key migration from other migration. Foreign key migration will not be run in the testing docker, to allow simpler db testing code.

That sounds like a very bad idea, always keep your testing as similar to production as possible. But I'm sure you have good reasons for that.


If you don't mind, I'd rather not add this: subfolders isn't something I'd like to recommend (things get confusing quickly, as different operating systems use different sorting methods for subfolders / normal files).

MigrationSource is an interface, so just drop a copy of your FileMigrationSource into your own project and use that, will work great and requires no changes to sql-migrate.

gemscng commented 5 years ago

@rubenv No problem.

gemscng commented 5 years ago

@rubenv

If you don't mind, I'd rather not add this: subfolders isn't something I'd like to recommend (things get confusing quickly, as different operating systems use different sorting methods for subfolders / normal files).

Just to be clear, the algorithm of my code just grab the file from the subfolder and see if there are folder to skip. The ordering of the migration is still depends on the file name of .sql. So this should not be a concern in different OS? Still subfolder can be a help when your system has more and more migration in the future.