This commit is contained in:
@@ -146,7 +146,7 @@ async fn copy_app_data(source_db: &Database, target_db: &Database) -> cot::Resul
|
||||
|
||||
async fn reset_postgres_sequences(db: &Database) -> cot::Result<()> {
|
||||
for table in [
|
||||
"cot_session__session",
|
||||
"cot__session",
|
||||
"amnezia_fellow__user",
|
||||
"amnezia_fellow__oidc_link",
|
||||
"amnezia_fellow__vpn_client",
|
||||
|
||||
+51
-1
@@ -1031,7 +1031,57 @@ pub mod db_migrations {
|
||||
&[Operation::custom(create_vpn_client_indexes).build()];
|
||||
}
|
||||
|
||||
pub const MIGRATIONS: &[&SyncDynMigration] = &[&M0005CreateVpnClient, &M0006VpnClientIndexes];
|
||||
#[cot::db::migrations::migration_op]
|
||||
async fn normalize_bigint_ids(ctx: migrations::MigrationContext<'_>) -> cot::db::Result<()> {
|
||||
if ctx
|
||||
.db
|
||||
.raw("SELECT current_setting('server_version_num')")
|
||||
.await
|
||||
.is_err()
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
for sql in [
|
||||
"ALTER TABLE amnezia_fellow__user ALTER COLUMN id TYPE BIGINT",
|
||||
"ALTER TABLE amnezia_fellow__user \
|
||||
ALTER COLUMN telegram_link_code_created_at TYPE BIGINT",
|
||||
"ALTER TABLE amnezia_fellow__oidc_link ALTER COLUMN id TYPE BIGINT",
|
||||
"ALTER TABLE amnezia_fellow__oidc_link ALTER COLUMN user_id TYPE BIGINT",
|
||||
"ALTER TABLE amnezia_fellow__vpn_client ALTER COLUMN id TYPE BIGINT",
|
||||
"ALTER TABLE amnezia_fellow__vpn_client ALTER COLUMN owner_user_id TYPE BIGINT",
|
||||
] {
|
||||
ctx.db.raw(sql).await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct M0009NormalizeBigintIds;
|
||||
|
||||
impl migrations::Migration for M0009NormalizeBigintIds {
|
||||
const APP_NAME: &'static str = "amnezia_fellow";
|
||||
const MIGRATION_NAME: &'static str = "m_0009_normalize_bigint_ids";
|
||||
const DEPENDENCIES: &'static [migrations::MigrationDependency] = &[
|
||||
migrations::MigrationDependency::migration(
|
||||
"amnezia_fellow",
|
||||
"m_0006_vpn_client_indexes",
|
||||
),
|
||||
migrations::MigrationDependency::migration(
|
||||
"amnezia_fellow",
|
||||
"m_0008_user_telegram_link_code",
|
||||
),
|
||||
];
|
||||
const OPERATIONS: &'static [Operation] =
|
||||
&[Operation::custom(normalize_bigint_ids).build()];
|
||||
}
|
||||
|
||||
pub const MIGRATIONS: &[&SyncDynMigration] = &[
|
||||
&M0005CreateVpnClient,
|
||||
&M0006VpnClientIndexes,
|
||||
&M0009NormalizeBigintIds,
|
||||
];
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user