Skip to content

Commit

Permalink
fix(migrations): add user IsActive and IsAdmin fields
Browse files Browse the repository at this point in the history
  • Loading branch information
dsonck92 committed Sep 5, 2024
1 parent 136f2c3 commit 9ddae2e
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions migrations/src/m20240905_000001_add_user_active_admin_fields.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright 2023 Daniël Sonck.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the GNU Affero General Public License v3.0 only, included in the file
// licenses/AGPL.txt.
use sea_orm_migration::prelude::*;

use crate::models::v1::User;

#[derive(DeriveEntityModel)]
pub struct Migration;

#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(
&self,
manager: &SchemaManager,
) -> Result<(), DbErr> {
manager
.alter_table(
Table::alter()
.table(User::Table)
.add_column(
ColumnDef::new(User::IsAdmin)
.boolean()
.not_null()
.default(false),
)
.add_column(
ColumnDef::new(User::IsActive)
.boolean()
.not_null()
.default(true),
)
.to_owned(),
)
.await?;

Ok(())
}

async fn down(
&self,
manager: &SchemaManager,
) -> Result<(), DbErr> {
manager
.alter_table(
Table::alter()
.table(User::Table)
.drop_column(User::IsActive)
.drop_column(User::IsAdmin)
.to_owned(),
)
.await?;
}
}

0 comments on commit 9ddae2e

Please sign in to comment.