68 lines
3.2 KiB
Rust
68 lines
3.2 KiB
Rust
//! Store browser Web Push subscriptions for client devices.
|
|||
|
|
|
||
|
|
#[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_0002_push_subscription";
|
||
|
|
const DEPENDENCIES: &'static [::cot::db::migrations::MigrationDependency] =
|
||
|
|
&[::cot::db::migrations::MigrationDependency::migration(
|
||
|
|
"web-petting",
|
||
|
|
"m_0001_initial",
|
||
|
|
)];
|
||
|
|
const OPERATIONS: &'static [::cot::db::migrations::Operation] = &[
|
||
|
|
::cot::db::migrations::Operation::create_model()
|
||
|
|
.table_name(::cot::db::Identifier::new("web_petting__push_subscription"))
|
||
|
|
.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("client_id"),
|
||
|
|
<cot::db::ForeignKey<crate::models::Client> as ::cot::db::DatabaseField>::TYPE,
|
||
|
|
)
|
||
|
|
.foreign_key(
|
||
|
|
<crate::models::Client as ::cot::db::Model>::TABLE_NAME,
|
||
|
|
<crate::models::Client as ::cot::db::Model>::PRIMARY_KEY_NAME,
|
||
|
|
::cot::db::ForeignKeyOnDeletePolicy::Restrict,
|
||
|
|
::cot::db::ForeignKeyOnUpdatePolicy::Restrict,
|
||
|
|
)
|
||
|
|
.set_null(<cot::db::ForeignKey<crate::models::Client> as ::cot::db::DatabaseField>::NULLABLE),
|
||
|
|
::cot::db::migrations::Field::new(
|
||
|
|
::cot::db::Identifier::new("endpoint"),
|
||
|
|
<String as ::cot::db::DatabaseField>::TYPE,
|
||
|
|
).set_null(false).unique(),
|
||
|
|
::cot::db::migrations::Field::new(
|
||
|
|
::cot::db::Identifier::new("p256dh"),
|
||
|
|
<String as ::cot::db::DatabaseField>::TYPE,
|
||
|
|
).set_null(false),
|
||
|
|
::cot::db::migrations::Field::new(
|
||
|
|
::cot::db::Identifier::new("auth"),
|
||
|
|
<String as ::cot::db::DatabaseField>::TYPE,
|
||
|
|
).set_null(false),
|
||
|
|
::cot::db::migrations::Field::new(
|
||
|
|
::cot::db::Identifier::new("language"),
|
||
|
|
<String as ::cot::db::DatabaseField>::TYPE,
|
||
|
|
).set_null(false),
|
||
|
|
::cot::db::migrations::Field::new(
|
||
|
|
::cot::db::Identifier::new("status"),
|
||
|
|
<String as ::cot::db::DatabaseField>::TYPE,
|
||
|
|
).set_null(false),
|
||
|
|
::cot::db::migrations::Field::new(
|
||
|
|
::cot::db::Identifier::new("created_at"),
|
||
|
|
<chrono::NaiveDateTime as ::cot::db::DatabaseField>::TYPE,
|
||
|
|
).set_null(false),
|
||
|
|
::cot::db::migrations::Field::new(
|
||
|
|
::cot::db::Identifier::new("updated_at"),
|
||
|
|
<chrono::NaiveDateTime as ::cot::db::DatabaseField>::TYPE,
|
||
|
|
).set_null(false),
|
||
|
|
])
|
||
|
|
.build(),
|
||
|
|
];
|
||
|
|
}
|