rubenv / sql-migrate

SQL schema migration tool for Go.
MIT License
3.18k stars 270 forks source link

Way to use with unittests #184

Closed hound672 closed 3 years ago

hound672 commented 3 years ago

Hello. Does anybody try to use this lib with unittests? Like Django, for example.

  1. Start unittest
  2. Up migrations for db
  3. Running unittest
  4. Down migrations
rubenv commented 3 years ago

I do, all the time. You might find a helper like this useful: https://github.com/rubenv/pgtest

On Wed, Nov 25, 2020, 07:19 Vasilii Bliznetsov notifications@github.com wrote:

Hello. Does anybody try to use this lib with unittests? Like Django, for example.

  1. Start unittest
  2. Up migrations for db
  3. Running unittest
  4. Down migrations

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rubenv/sql-migrate/issues/184, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAKPGHKSNSBNRA75LNLBQLSRSOXPANCNFSM4UB6DISA .

hound672 commented 3 years ago

Thanks. But it does not up/down migrations.

rubenv commented 3 years ago

No but it does provide you with a clean server to test against. Doing the up/down is just a matter of calling the library.

On Wed, Nov 25, 2020, 07:37 Vasilii Bliznetsov notifications@github.com wrote:

Thanks. But it does not up/down migrations.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rubenv/sql-migrate/issues/184#issuecomment-733500075, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAKPGEILGUOPUMD32PORLDSRSQ2DANCNFSM4UB6DISA .

hound672 commented 3 years ago

I'd like to create db by my own. For example, I have 2 environments in dbconfig.yml:

  1. testing
  2. develop with different credentials, db name etc.

Could I up/down migrations in golang unittests with this config (with testing env)?

rubenv commented 3 years ago

The config file is for the CLI tool, but you can do anything the CLI does with the library.

On Wed, Nov 25, 2020, 07:50 Vasilii Bliznetsov notifications@github.com wrote:

I'd like to create db by my own. For example, I have 2 environments in dbconfig.yml:

  1. testing
  2. develop with different credentials, db name etc.

Could I up/down migrations in golang unittests with this config (with testing env)?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rubenv/sql-migrate/issues/184#issuecomment-733505141, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAKPGEQVYRXVKGAL6OPFFDSRSSK7ANCNFSM4UB6DISA .

hound672 commented 3 years ago

Ok, thanks. I will try in this way.