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
Open

Comments

@westonganger
Copy link

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
Copy link
Owner

plentz 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
Copy link
Author

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
Copy link
Owner

plentz 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
Copy link
Author

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
Projects
None yet
Development

No branches or pull requests

2 participants