57 lines
2.7 KiB
Rust
57 lines
2.7 KiB
Rust
//! Migration: create Testimonial table
|
|
|
|
#[derive(Debug, Copy, Clone)]
|
|
pub(super) struct Migration;
|
|
impl ::cot::db::migrations::Migration for Migration {
|
|
const APP_NAME: &'static str = "web-petting";
|
|
const MIGRATION_NAME: &'static str = "m_0005_testimonials";
|
|
const DEPENDENCIES: &'static [::cot::db::migrations::MigrationDependency] =
|
|
&[::cot::db::migrations::MigrationDependency::migration(
|
|
"web-petting",
|
|
"m_0004_visit_public_notes",
|
|
)];
|
|
const OPERATIONS: &'static [::cot::db::migrations::Operation] =
|
|
&[::cot::db::migrations::Operation::create_model()
|
|
.table_name(::cot::db::Identifier::new("web_petting__testimonial"))
|
|
.fields(&[
|
|
::cot::db::migrations::Field::new(
|
|
::cot::db::Identifier::new("id"),
|
|
<cot::db::Auto<i64> as ::cot::db::DatabaseField>::TYPE,
|
|
)
|
|
.auto()
|
|
.primary_key()
|
|
.set_null(<cot::db::Auto<i64> as ::cot::db::DatabaseField>::NULLABLE),
|
|
::cot::db::migrations::Field::new(
|
|
::cot::db::Identifier::new("text"),
|
|
<String as ::cot::db::DatabaseField>::TYPE,
|
|
)
|
|
.set_null(<String as ::cot::db::DatabaseField>::NULLABLE),
|
|
::cot::db::migrations::Field::new(
|
|
::cot::db::Identifier::new("author_note"),
|
|
<Option<String> as ::cot::db::DatabaseField>::TYPE,
|
|
)
|
|
.set_null(<Option<String> as ::cot::db::DatabaseField>::NULLABLE),
|
|
::cot::db::migrations::Field::new(
|
|
::cot::db::Identifier::new("image_path"),
|
|
<Option<String> as ::cot::db::DatabaseField>::TYPE,
|
|
)
|
|
.set_null(<Option<String> as ::cot::db::DatabaseField>::NULLABLE),
|
|
::cot::db::migrations::Field::new(
|
|
::cot::db::Identifier::new("status"),
|
|
<String as ::cot::db::DatabaseField>::TYPE,
|
|
)
|
|
.set_null(<String as ::cot::db::DatabaseField>::NULLABLE),
|
|
::cot::db::migrations::Field::new(
|
|
::cot::db::Identifier::new("sort_order"),
|
|
<i32 as ::cot::db::DatabaseField>::TYPE,
|
|
)
|
|
.set_null(<i32 as ::cot::db::DatabaseField>::NULLABLE),
|
|
::cot::db::migrations::Field::new(
|
|
::cot::db::Identifier::new("created_at"),
|
|
<chrono::NaiveDateTime as ::cot::db::DatabaseField>::TYPE,
|
|
)
|
|
.set_null(<chrono::NaiveDateTime as ::cot::db::DatabaseField>::NULLABLE),
|
|
])
|
|
.build()];
|
|
}
|