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

Create differently titled migration if migration exists already #55

Open
westonganger opened this issue Apr 21, 2015 · 4 comments

Comments

Projects
None yet
2 participants
@westonganger
Copy link

commented Apr 21, 2015

I have previously run rails g migration AddMissingIndexes

I wanted to run it again but there is a name clash with the previous migration. Would be helpful it it automatically added a number to the name or something or had an options to manually change the name

@plentz plentz added the enhancement label May 2, 2015

@plentz

This comment has been minimized.

Copy link
Owner

commented May 2, 2015

@westonganger PR's are welcome. All you need to do is check if the file already exists before printing this message.

@westonganger

This comment has been minimized.

Copy link
Author

commented Jun 3, 2015

I misunderstood what this was supposed to do. I thought it automatically created a migration file. The best solution I came up with was this but its probably not great and im not sure if using system commands are frowned upon and it will probably slow down the command somewhat significantly.

`bundle exec rake db:migrate:status | grep 'Add missing indexes'`.scan(/Add missing indexes/).count

I would then take that number+1 and append it to the migration name. I also may have to check for existance of bundler gem too.

Let me know what you think, if I shouldn't bother then you can just close the issue.

@plentz

This comment has been minimized.

Copy link
Owner

commented Jun 4, 2015

@westonganger I think that the idea of getting the count is cool, but this way we will depend on grep. I think that's better to use ruby's File API to check if we already have any migration. What do you think?

@westonganger

This comment has been minimized.

Copy link
Author

commented Jun 4, 2015

Yeah that would be better I just whipped it up quickly. Now that we are ensuring its an unused name is it desired to actually run rails g migration AddMissingIndexes3 and fill the file with the information?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.