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

Support creating a table migration generator #8652

Merged
merged 1 commit into from Mar 1, 2013

Conversation

Projects
None yet
6 participants
@codeodor
Contributor

codeodor commented Dec 29, 2012

Sometimes you want to create a table without an associated model and test, which is also not a join table. With this commit, you can now do that.

I've typed these commands enough times over the years and ended up with empty migrations that I finally decided to add them to Rails and see if anyone else considered it useful.

Example:

rails g migration create_posts title:string

or

rails g migration CreatePosts title:string

This commit also moves the template the model generator uses for the migration to the migration templates folder, as it seems a more sensible place for it now that it is shared code.

@steveklabnik

View changes

Show outdated Hide outdated activerecord/CHANGELOG.md Outdated
@steveklabnik

This comment has been minimized.

Show comment
Hide comment
@steveklabnik

steveklabnik Feb 25, 2013

Member

I like it. 👍

Member

steveklabnik commented Feb 25, 2013

I like it. 👍

@codeodor

This comment has been minimized.

Show comment
Hide comment
@codeodor

codeodor Feb 25, 2013

Contributor

Thanks Steve. When you say "this needs to be moved to the top," what are you referring to? That I need to move the changelog entry to the top of the file instead of the bottom of the file?

Sam

Contributor

codeodor commented Feb 25, 2013

Thanks Steve. When you say "this needs to be moved to the top," what are you referring to? That I need to move the changelog entry to the top of the file instead of the bottom of the file?

Sam

@robin850

This comment has been minimized.

Show comment
Hide comment
@robin850

robin850 Feb 25, 2013

Member

Seems good. I'm 👍 on this!

I allow myself to answer your question : yes, you should move your changelog entry to the top of the file.

Thanks for your contribution! :)

Member

robin850 commented Feb 25, 2013

Seems good. I'm 👍 on this!

I allow myself to answer your question : yes, you should move your changelog entry to the top of the file.

Thanks for your contribution! :)

@steveklabnik

This comment has been minimized.

Show comment
Hide comment
@steveklabnik

steveklabnik Feb 25, 2013

Member

Yes, I mean it should be at the top of the file.

Member

steveklabnik commented Feb 25, 2013

Yes, I mean it should be at the top of the file.

end
protected
attr_reader :migration_action, :join_tables
def set_local_assigns!
@migration_template = "migration.rb"

This comment has been minimized.

@rafaelfranca

rafaelfranca Feb 25, 2013

Member

This file don't exist anymore since you moved to create_table_migration

@rafaelfranca

rafaelfranca Feb 25, 2013

Member

This file don't exist anymore since you moved to create_table_migration

This comment has been minimized.

@codeodor

codeodor Feb 25, 2013

Contributor

This file still exists and is the default file for taking care of the other migrations. See Line 30-32 where it uses create_table_migration.rb for migrations which create tables.

Do you have any suggestion for how I can improve the code to make this more obvious/clear?

@codeodor

codeodor Feb 25, 2013

Contributor

This file still exists and is the default file for taking care of the other migrations. See Line 30-32 where it uses create_table_migration.rb for migrations which create tables.

Do you have any suggestion for how I can improve the code to make this more obvious/clear?

This comment has been minimized.

@rafaelfranca

rafaelfranca Feb 25, 2013

Member

The code is obvious the problem was github with the misleading information that the file was renamed.

Screen Shot 2013-02-25 at 10 45 55

Sorry

@rafaelfranca

rafaelfranca Feb 25, 2013

Member

The code is obvious the problem was github with the misleading information that the file was renamed.

Screen Shot 2013-02-25 at 10 45 55

Sorry

This comment has been minimized.

@codeodor

codeodor Feb 25, 2013

Contributor

Thanks for letting me know. I'll try to be more clear next time. For what it's worth, the file did get moved: it used to live with the model generator, while now it is with the migration generator.

@codeodor

codeodor Feb 25, 2013

Contributor

Thanks for letting me know. I'll try to be more clear next time. For what it's worth, the file did get moved: it used to live with the model generator, while now it is with the migration generator.

@codeodor

This comment has been minimized.

Show comment
Hide comment
@codeodor

codeodor Feb 25, 2013

Contributor

Ok, I moved the changelog entry to the top of the file.

Any other feedback? (for example, should I pull from rails/master and merge?)

Contributor

codeodor commented Feb 25, 2013

Ok, I moved the changelog entry to the top of the file.

Any other feedback? (for example, should I pull from rails/master and merge?)

@rafaelfranca

This comment has been minimized.

Show comment
Hide comment
@rafaelfranca

rafaelfranca Feb 25, 2013

Member

Could you squash the commits and rebase against master? It cannot be automatically merged

Member

rafaelfranca commented Feb 25, 2013

Could you squash the commits and rebase against master? It cannot be automatically merged

@codeodor

This comment has been minimized.

Show comment
Hide comment
@codeodor

codeodor Feb 25, 2013

Contributor

Ok, I rebased onto master, and the PR contains one commit. How does it look now?

Contributor

codeodor commented Feb 25, 2013

Ok, I rebased onto master, and the PR contains one commit. How does it look now?

@milushov

This comment has been minimized.

Show comment
Hide comment
@milushov

milushov Mar 1, 2013

👍 👍 👍

milushov commented Mar 1, 2013

👍 👍 👍

@carlosantoniodasilva

This comment has been minimized.

Show comment
Hide comment
@carlosantoniodasilva

carlosantoniodasilva Mar 1, 2013

Member

Looks good 👍. But github says it cannot be automatically merged, can you please rebase again? (it's likely a changelog conflict).

Member

carlosantoniodasilva commented Mar 1, 2013

Looks good 👍. But github says it cannot be automatically merged, can you please rebase again? (it's likely a changelog conflict).

Support creating a table migration generator
Sometimes you want to create a table without an associated model and
test, which is also not a join table. With this commit, you can now
do that.

Example:

    rails g migration create_posts title:string
or
    rails g migration CreatePosts title:string

This commit also moves the template the model generator uses for the
migration to the migration templates folder, as it seems a more
sensible place for it now that it is shared code.
@codeodor

This comment has been minimized.

Show comment
Hide comment
@codeodor

codeodor Mar 1, 2013

Contributor

Ok, done. Does it say it will merge cleanly?

Contributor

codeodor commented Mar 1, 2013

Ok, done. Does it say it will merge cleanly?

@carlosantoniodasilva

This comment has been minimized.

Show comment
Hide comment
@carlosantoniodasilva

carlosantoniodasilva Mar 1, 2013

Member

Yup it does. Thank you!

Member

carlosantoniodasilva commented Mar 1, 2013

Yup it does. Thank you!

carlosantoniodasilva added a commit that referenced this pull request Mar 1, 2013

Merge pull request #8652 from codeodor/create_table_migration
Support creating a table migration generator

Sometimes you want to create a table without an associated model and
test, which is also not a join table. With this commit, you can now
do that.

Example:

    rails g migration create_posts title:string
or
    rails g migration CreatePosts title:string

This commit also moves the template the model generator uses for the
migration to the migration templates folder, as it seems a more
sensible place for it now that it is shared code.

@carlosantoniodasilva carlosantoniodasilva merged commit b49a2a7 into rails:master Mar 1, 2013

@codeodor

This comment has been minimized.

Show comment
Hide comment
@codeodor

codeodor Mar 1, 2013

Contributor

Awesome, thanks! 👍 ❤️

Contributor

codeodor commented Mar 1, 2013

Awesome, thanks! 👍 ❤️

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