use sea_orm::sea_query::{ColumnDef, Table};
use sea_orm::{DbErr, DeriveIden};
use sea_orm_migration::{MigrationName, MigrationTrait, SchemaManager};
pub struct Migration;
impl MigrationName for Migration {
fn name(&self) -> &str {
"m_20261019_000016_create_note"
}
}
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(
Table::create()
.table(Note::Table)
.col(
ColumnDef::new(Note::Id)
.integer()
.not_null()
.auto_increment()
.primary_key(),
)
.col(ColumnDef::new(Note::Kind).string().not_null())
.col(ColumnDef::new(Note::Text).string().not_null())
.col(ColumnDef::new(Note::Done).boolean().not_null())
.col(ColumnDef::new(Note::Date).date().not_null())
.col(ColumnDef::new(Note::Calendar).string().null())
.col(ColumnDef::new(Note::Event).string().null())
.col(ColumnDef::new(Note::SigDateId).integer().null())
.col(ColumnDef::new(Note::DateIns).date().not_null())
.col(ColumnDef::new(Note::DateUp).date().not_null())
.to_owned(),
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(Table::drop().table(Note::Table).to_owned())
.await
}
}
/// A note or todo on one occurrence of a date: a holiday or iCal event (calendar + event
/// name) or a person's date (sig_date_id), on a given day
#[derive(DeriveIden)]
pub enum Note {
Table,
Id,
Kind, // note or todo
Text,
Done,
Date,
Calendar,
Event,
SigDateId,
DateIns,
DateUp,
}
⭐
Log in to mark this repository.
2.0 KiB · text
History
aea77cc