pique/_experiments/2024-03-02-database-benchmark/migration/src/m20240307_110706_create_tables.rs
Nicole Tietz-Sokolskaya 77d4ebb371 Add ADR for our choice of SQLite as our primary database,
backed up by experiments demonstrating that SQLite will meet all of our
requirements.

This also introduces ADRs in the repo, and adds a README in preparation
making the repository public.
2024-03-16 11:12:46 -04:00

54 lines
1.4 KiB
Rust

use std::fmt;
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> {
manager
.create_table(
Table::create()
.table(Page::Table)
.if_not_exists()
.col(
ColumnDef::new(Page::Id)
.integer()
.not_null()
.auto_increment()
.primary_key(),
)
.col(ColumnDef::new(Page::ExternalId).big_integer().not_null())
.col(ColumnDef::new(Page::Title).string().not_null())
.col(ColumnDef::new(Page::Text).string().not_null())
//.col(ColumnDef::new(Page::Text).custom(LongText).not_null())
.to_owned(),
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(Table::drop().table(Page::Table).to_owned())
.await
}
}
pub struct LongText;
impl Iden for LongText {
fn unquoted(&self, s: &mut dyn fmt::Write) {
s.write_str("LongText").unwrap();
}
}
#[derive(DeriveIden)]
enum Page {
Table,
Id,
ExternalId,
Title,
Text,
}