65 lines
2.2 KiB
Rust
65 lines
2.2 KiB
Rust
//! SeaORM migration: extend project_billing with pro/quota fields
|
|
|
|
use sea_orm_migration::prelude::*;
|
|
|
|
pub struct Migration;
|
|
|
|
impl MigrationName for Migration {
|
|
fn name(&self) -> &str {
|
|
"m20260509_000003_extend_project_billing"
|
|
}
|
|
}
|
|
|
|
#[async_trait::async_trait]
|
|
impl MigrationTrait for Migration {
|
|
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
|
let sql = include_str!("sql/m20260509_000003_extend_project_billing.sql");
|
|
super::execute_sql(manager, sql).await
|
|
}
|
|
|
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
|
manager
|
|
.get_connection()
|
|
.execute_raw(sea_orm::Statement::from_string(
|
|
sea_orm::DbBackend::Postgres,
|
|
"ALTER TABLE project_billing DROP COLUMN IF EXISTS initial_credit_granted;",
|
|
))
|
|
.await?;
|
|
manager
|
|
.get_connection()
|
|
.execute_raw(sea_orm::Statement::from_string(
|
|
sea_orm::DbBackend::Postgres,
|
|
"ALTER TABLE project_billing DROP COLUMN IF EXISTS is_pro;",
|
|
))
|
|
.await?;
|
|
manager
|
|
.get_connection()
|
|
.execute_raw(sea_orm::Statement::from_string(
|
|
sea_orm::DbBackend::Postgres,
|
|
"ALTER TABLE project_billing DROP COLUMN IF EXISTS monthly_quota;",
|
|
))
|
|
.await?;
|
|
manager
|
|
.get_connection()
|
|
.execute_raw(sea_orm::Statement::from_string(
|
|
sea_orm::DbBackend::Postgres,
|
|
"ALTER TABLE project_billing DROP COLUMN IF EXISTS month_used;",
|
|
))
|
|
.await?;
|
|
manager
|
|
.get_connection()
|
|
.execute_raw(sea_orm::Statement::from_string(
|
|
sea_orm::DbBackend::Postgres,
|
|
"ALTER TABLE project_billing DROP COLUMN IF EXISTS cycle_start;",
|
|
))
|
|
.await?;
|
|
manager
|
|
.get_connection()
|
|
.execute_raw(sea_orm::Statement::from_string(
|
|
sea_orm::DbBackend::Postgres,
|
|
"ALTER TABLE project_billing DROP COLUMN IF EXISTS cycle_end;",
|
|
))
|
|
.await?;
|
|
Ok(())
|
|
}
|
|
} |