-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update db calls to not use dates in pks & reduce dupe key failur…
…es. closes #18
- Loading branch information
Showing
9 changed files
with
102 additions
and
28 deletions.
There are no files selected for viewing
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
55 changes: 55 additions & 0 deletions
55
migration/src/m20230918_033709_remove_junk_pk_from_listing.rs
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,55 @@ | ||
use sea_orm_migration::prelude::*; | ||
|
||
use crate::m20220101_000001_create_table::{ActiveListing, SaleHistory}; | ||
|
||
#[derive(DeriveMigrationName)] | ||
pub struct Migration; | ||
|
||
#[async_trait::async_trait] | ||
impl MigrationTrait for Migration { | ||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { | ||
// alter table sale_history | ||
// drop constraint sale_history_pkey; | ||
|
||
// alter table sale_history | ||
// add primary key (id); | ||
manager | ||
.drop_foreign_key( | ||
ForeignKeyDropStatement::new() | ||
.table(SaleHistory::Table) | ||
.name("sale_history_pkey") | ||
.to_owned(), | ||
) | ||
.await?; | ||
manager | ||
.alter_table( | ||
TableAlterStatement::new() | ||
.modify_column(ColumnDef::new(SaleHistory::Id).primary_key()) | ||
.table(SaleHistory::Table) | ||
.to_owned(), | ||
) | ||
.await?; | ||
manager | ||
.drop_foreign_key( | ||
ForeignKeyDropStatement::new() | ||
.table(ActiveListing::Table) | ||
.name("active_listing_pkey") | ||
.to_owned(), | ||
) | ||
.await?; | ||
manager | ||
.alter_table( | ||
TableAlterStatement::new() | ||
.modify_column(ColumnDef::new(ActiveListing::Id).primary_key()) | ||
.table(ActiveListing::Table) | ||
.to_owned(), | ||
) | ||
.await?; | ||
Ok(()) | ||
} | ||
|
||
async fn down(&self, _manager: &SchemaManager) -> Result<(), DbErr> { | ||
// Replace the sample below with your own migration scripts | ||
todo!(); | ||
} | ||
} |
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
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
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