Auto-create check constraints for text fields with limit

Move column defaults from migration strategy to migrations.
Compact index creation inside migrations.
Disable database schema generation.
This commit is contained in:
2026-11-26 02:32:09 +01:00
parent 74f9a09098
commit b6d2c19b0b
9 changed files with 148 additions and 210 deletions
@@ -1,24 +1,24 @@
class AddDeviseToUsers < ActiveRecord::Migration[8.1]
def change
change_table :users do |t|
## NOTE: commented fields left for reference/inclusion in future migrations
## Commented fields left for reference/inclusion in future migrations.
## Database authenticatable
t.string :encrypted_password, null: false, default: ""
## Recoverable
t.string :reset_password_token
t.string :reset_password_token, index: {unique: true}
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## Confirmable
t.string :confirmation_token
t.string :confirmation_token, index: {unique: true}
t.datetime :confirmed_at
t.datetime :confirmation_sent_at
# Only if using reconfirmable
t.string :unconfirmed_email, limit: 64
# Only if using reconfirmable.
t.string :unconfirmed_email, limit: 2**6
## Trackable
# t.integer :sign_in_count, default: 0, null: false
@@ -28,14 +28,11 @@ class AddDeviseToUsers < ActiveRecord::Migration[8.1]
# t.string :last_sign_in_ip
## Lockable
# t.string :unlock_token # Only if unlock strategy is :email or :both
# Only if unlock strategy is :email or :both.
# t.string :unlock_token, index: {unique: true}
# t.datetime :locked_at
# Only if lock strategy is :failed_attempts
# Only if lock strategy is :failed_attempts.
# t.integer :failed_attempts, default: 0, null: false
end
add_index :users, :reset_password_token
add_index :users, :confirmation_token
# add_index :users, :unlock_token, unique: true
end
end