7

I am using migrate to create SQL database schema and populate it with initial data. Later SQLAlchemy is used to work with this DB.

How could I test that my SQLAlchemy models are relevant/correct for real DB schema generated by migrate?

Roman Bodnarchuk
  • 29,461
  • 12
  • 59
  • 75
  • Do a migrate again and filecompare? Heres an extensive help btw: https://sqlalchemy-migrate.readthedocs.org/en/v0.7.2/versioning.html – Alfons Apr 01 '14 at 16:11
  • 2
    FYI, if you are still using `sqlalchemy-migrate`, you should switch to `alembic` (http://stackoverflow.com/questions/4209705/is-it-worth-using-sqlalchemy-migrate). – alecxe Apr 02 '14 at 14:41
  • @Alfons Yes, but how will I know that my DB after all migrations exactly matches SQLAlchemy models? – Roman Bodnarchuk Apr 02 '14 at 15:57

1 Answers1

1

I didn't test it, but in the features list, this tool seems to do want you want:

http://metacpan.org/pod/SQL::Translator::Manual

*FINDING THE DIFFERENCES BETWEEN TWO SCHEMAS As mentioned above, the "sqlt-diff" schema examines two schemas and creates SQL schema modification statements that can be used to transform the first schema into the second. The flag syntax is somewhat quirky:

$ sqlt-diff foo-v1.sql=MySQL foo-v2.sql=Oracle > diff.sql*

main tool page: http://sqlfairy.sourceforge.net/

szabgab
  • 6,202
  • 11
  • 50
  • 64
Nelson Teixeira
  • 6,297
  • 5
  • 36
  • 73