mirror of
https://github.com/OMGeeky/twitch_backup.local_db.git
synced 2026-01-01 17:14:37 +01:00
add field timezone to users
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "twba-local-db"
|
||||
version = "0.2.1"
|
||||
version = "0.3.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
@@ -9,13 +9,13 @@ edition = "2021"
|
||||
|
||||
sea-orm = { version = "0.12", features = ["sqlx-sqlite", "runtime-tokio-rustls", "macros"] }
|
||||
sea-orm-migration = "0.12"
|
||||
tokio = { version = "1.33" , features = ["full"]}
|
||||
tokio = { version = "1.33", features = ["full"] }
|
||||
thiserror = "1.0"
|
||||
futures = "0.3"
|
||||
tracing = "0.1"
|
||||
|
||||
anyhow = { version = "1.0" , optional = true}
|
||||
tracing-subscriber = { version = "0.3" ,optional = true}
|
||||
anyhow = { version = "1.0", optional = true }
|
||||
tracing-subscriber = { version = "0.3", optional = true }
|
||||
|
||||
[features]
|
||||
build-binary = ["anyhow", "tracing-subscriber"]
|
||||
|
||||
@@ -26,6 +26,7 @@ pub struct Model {
|
||||
/// be split into multiple parts.
|
||||
pub youtube_max_duration: i32,
|
||||
pub active: bool,
|
||||
pub timezone: String,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
|
||||
14
src/lib.rs
14
src/lib.rs
@@ -1,10 +1,3 @@
|
||||
use crate::entities::video_upload::UploadStatus;
|
||||
use crate::{
|
||||
entities::prelude::{Users, VideoUpload, Videos},
|
||||
entities::status::Status,
|
||||
entities::*,
|
||||
migrator::Migrator,
|
||||
};
|
||||
use sea_orm::ActiveValue::Set;
|
||||
use sea_orm::{
|
||||
ActiveModelTrait, ActiveValue, ColumnTrait, Database, DatabaseConnection, DbErr, EntityTrait,
|
||||
@@ -12,6 +5,13 @@ use sea_orm::{
|
||||
};
|
||||
use sea_orm_migration::MigratorTrait;
|
||||
use tracing::{info, instrument};
|
||||
use {
|
||||
entities::prelude::{Users, VideoUpload, Videos},
|
||||
entities::status::Status,
|
||||
entities::video_upload::UploadStatus,
|
||||
entities::*,
|
||||
migrator::Migrator,
|
||||
};
|
||||
|
||||
pub mod entities;
|
||||
mod migrator;
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
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
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(Users::Table)
|
||||
.add_column(
|
||||
ColumnDef::new(Users::Timezone)
|
||||
.string()
|
||||
.not_null()
|
||||
.default("+00:00"),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(Users::Table)
|
||||
.drop_column(Users::Timezone)
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Iden)]
|
||||
pub enum Users {
|
||||
Table,
|
||||
Timezone,
|
||||
}
|
||||
@@ -6,6 +6,8 @@ mod m20230916_000003_create_video_upload_table;
|
||||
mod m20230916_000004_add_sample_data;
|
||||
mod m20231015_000005_alter_videos_table_for_errors;
|
||||
mod m20231029_000006_alter_video_uploads_table_for_youtube_id;
|
||||
mod m20240509_000006_alter_users_table_for_timezone;
|
||||
|
||||
pub struct Migrator;
|
||||
#[async_trait::async_trait]
|
||||
impl MigratorTrait for Migrator {
|
||||
@@ -14,9 +16,10 @@ impl MigratorTrait for Migrator {
|
||||
Box::new(m20230916_000001_create_users_table::Migration),
|
||||
Box::new(m20230916_000002_create_videos_table::Migration),
|
||||
Box::new(m20230916_000003_create_video_upload_table::Migration),
|
||||
// Box::new(m20230916_000004_add_sample_data::Migration),
|
||||
Box::new(m20230916_000004_add_sample_data::Migration),
|
||||
Box::new(m20231015_000005_alter_videos_table_for_errors::Migration),
|
||||
Box::new(m20231029_000006_alter_video_uploads_table_for_youtube_id::Migration),
|
||||
Box::new(m20240509_000006_alter_users_table_for_timezone::Migration),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user