Skip to content
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

Should migrate display a warning when no commands are executed? #8

Closed
t-richards opened this issue May 14, 2018 · 3 comments
Closed

Comments

@t-richards
Copy link

t-richards commented May 14, 2018

I read through the README for v0.2.0 and saw the following migration syntax:

-- +migrate up
CREATE TABLE foo (
  id SERIAL PRIMARY KEY
);

-- +migrate down
DROP TABLE foo;

After creating the above migration, I added migrate.cr to my application's dependencies, but failed to notice that shards pulled down the previous version instead, v0.1.1. v0.1.1 still uses !migrate as the command prefix. I configured migrate via code and ran it. Migrate's log output shows that everything is successful:

migrator.to_latest
# => Successfully migrated from version 0 to 1 in 28.449ms

I was confused... migrating up didn't create the table! Especially after creating the table manually and then migrating down to find it was not, in fact, dropped. The above output of migrate is technically correct. The commands which were executed (none!) were not unsuccessful, therefore the migration succeeds.

I believe this raises an important question. Should migrate display a warning when no commands are executed in a migration? If a warning were displayed, it would have helped me not waste a silly amount of time because of a dumb mistake.

@vladfaust
Copy link
Owner

Hello, @t-richards. You can specify tag: v0.2.0-pre.1 in dependencies, so it installs the latest version. As far as I understand, the issue is that it displays success message even if the migration file is empty or formatted incorrectly, right?

@t-richards
Copy link
Author

As far as I understand, the issue is that it displays success message even if the migration file is empty or formatted incorrectly, right?

Correct. Is this the intended behavior and I just have to be extra careful, or would it be appropriate to display some kind of message in these situations?

@vladfaust
Copy link
Owner

I agree that it should display a warning message 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants