Skip to content

Add not-null modifier to migrations#52327

Merged
dhh merged 5 commits intomainfrom
add-not-null-modifier-to-migrations
Jul 16, 2024
Merged

Add not-null modifier to migrations#52327
dhh merged 5 commits intomainfrom
add-not-null-modifier-to-migrations

Conversation

@dhh
Copy link
Member

@dhh dhh commented Jul 14, 2024

# Generating with...
bin/rails generate migration CreateUsers email_address:string!:uniq password_digest:string!

# Produces:
class CreateUsers < ActiveRecord::Migration[8.0]
  def change
    create_table :users do |t|
      t.string :email_address, null: false
      t.string :password_digest, null: false

      t.timestamps
    end
    add_index :users, :email_address, unique: true
  end
end

@rails-bot rails-bot bot added the railties label Jul 14, 2024
@dhh
Copy link
Member Author

dhh commented Jul 16, 2024

Unrelated test failures.

@dhh dhh merged commit 2f92b1c into main Jul 16, 2024
@dhh dhh deleted the add-not-null-modifier-to-migrations branch July 16, 2024 12:37
Schwad pushed a commit to Shopify/rails that referenced this pull request Jul 18, 2024
* Add migration type modifier for not-null attributes

* Explain change

* Appease rubocop by using AS helper

* Deal with nil
DanielaVelasquez pushed a commit to DanielaVelasquez/rails that referenced this pull request Oct 3, 2024
* Add migration type modifier for not-null attributes

* Explain change

* Appease rubocop by using AS helper

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants