Is it possible to set the DB default value in migration? #1260
-
If this is already a feature, I would be very happy to know! Rails create_table :users do |t|
t.string :email, null: false, unique: true
t.integer :status, default: 0 # like this!
t.timestamps
end add_column :users, :step, :integer, default: 1 # like this! Loco, How to set? async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(
table_auto_tz(Languages::Table)
.col(pk_auto(Languages::Id))
.col(string(Languages::Name))
.col(integer(Languages::LanguageType))
.to_owned(),
)
.await
} async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
add_column(m, "engineers", "is_approved", ColType::Boolean).await?;
Ok(())
} |
Beta Was this translation helpful? Give feedback.
Answered by
kaplanelad
Feb 19, 2025
Replies: 1 comment 2 replies
-
Hey @manabu0926, |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
kaplanelad
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @manabu0926,
Currently, is not supported, but it would be great to have it!
Please feel free to open an issue, and we can talk about the possibility of implementing it.