-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
59 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use sea_orm::{ConnectionTrait, Statement}; | ||
use sea_orm_migration::prelude::*; | ||
#[derive(DeriveMigrationName)] | ||
pub struct Migration; | ||
|
||
#[async_trait::async_trait] | ||
impl MigrationTrait for Migration { | ||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { | ||
let sql = r#" | ||
ALTER TABLE remotes | ||
ADD COLUMN last_sync_timestamp INTEGER DEFAULT 0; | ||
UPDATE remotes | ||
SET last_sync_timestamp = 0 | ||
WHERE last_sync_timestamp IS NULL; | ||
"#; | ||
let stmt = Statement::from_string(manager.get_database_backend(), sql.to_owned()); | ||
manager.get_connection().execute(stmt).await.map(|_| ()) | ||
} | ||
|
||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { | ||
let sql = r#" | ||
ALTER TABLE remotes | ||
DROP COLUMN last_sync_timestamp; | ||
"#; | ||
let stmt = Statement::from_string(manager.get_database_backend(), sql.to_owned()); | ||
manager.get_connection().execute(stmt).await.map(|_| ()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters