Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Phil Pirozhkov <[email protected]>
  • Loading branch information
armandmgt and pirj authored Jan 14, 2025
1 parent 712c833 commit 9b4ee46
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1183,14 +1183,16 @@ create_table :users do |t|
t.boolean :active
end
# bad - adding a boolean without a `NOT NULL` constraint or without a default value
# bad - adding a boolean column without a `NOT NULL` constraint or without a default value to an existing table
add_column :users, :active, :boolean
add_column :users, :active, :boolean, null: false
# good - boolean with a `NOT NULL` constraint, and a default value (`false` or `true`) for existing tables
# good - boolean column with a `NOT NULL` constraint for new tables
create_table :users do |t|
t.boolean :active, null: false
end
# good - boolean column with a `NOT NULL` constraint, and a default value (`false` or `true`) for existing tables
add_column :users, :active, :boolean, default: true, null: false
add_column :users, :admin, :boolean, default: false, null: false
----
Expand Down

0 comments on commit 9b4ee46

Please sign in to comment.