eshop
Some checks failed
CI / Check Style (push) Has been cancelled
CI / Run Clippy (push) Has been cancelled
CI / Run Tests (push) Has been cancelled

This commit is contained in:
Priec
2026-06-16 16:35:50 +02:00
parent c4f60dd8d7
commit baf7522273
87 changed files with 3270 additions and 3483 deletions

View File

@@ -15,6 +15,15 @@ mod m20260517_000010_drop_user_roles;
mod m20260517_000011_site_pages;
mod m20260517_000012_standalone_audio_tracks;
mod m20260616_123506_categories;
mod m20260616_123524_products;
mod m20260616_123550_product_images;
mod m20260616_123611_product_tags;
mod m20260616_123957_create_join_table_products_and_product_tags;
mod m20260616_130610_orders;
mod m20260616_130628_order_items;
mod m20260616_131000_drop_audio_tables;
mod m20260616_132000_drop_blog_and_pages;
pub struct Migrator;
#[async_trait::async_trait]
@@ -34,7 +43,16 @@ impl MigratorTrait for Migrator {
Box::new(m20260517_000010_drop_user_roles::Migration),
Box::new(m20260517_000011_site_pages::Migration),
Box::new(m20260517_000012_standalone_audio_tracks::Migration),
Box::new(m20260616_123506_categories::Migration),
Box::new(m20260616_123524_products::Migration),
Box::new(m20260616_123550_product_images::Migration),
Box::new(m20260616_123611_product_tags::Migration),
Box::new(m20260616_123957_create_join_table_products_and_product_tags::Migration),
Box::new(m20260616_130610_orders::Migration),
Box::new(m20260616_130628_order_items::Migration),
Box::new(m20260616_131000_drop_audio_tables::Migration),
Box::new(m20260616_132000_drop_blog_and_pages::Migration),
// inject-above (do not remove this comment)
]
}
}
}

View File

@@ -0,0 +1,30 @@
use loco_rs::schema::*;
use sea_orm_migration::prelude::*;
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
create_table(m, "categories",
&[
("id", ColType::PkAuto),
("name", ColType::String),
("slug", ColType::StringUniq),
("description", ColType::TextNull),
("image_id", ColType::StringNull),
("position", ColType::IntegerWithDefault(0)),
("published", ColType::BooleanWithDefault(false)),
],
&[
]
).await
}
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
drop_table(m, "categories").await
}
}

View File

@@ -0,0 +1,35 @@
use loco_rs::schema::*;
use sea_orm_migration::prelude::*;
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
create_table(m, "products",
&[
("id", ColType::PkAuto),
("name", ColType::String),
("slug", ColType::StringUniq),
("description", ColType::TextNull),
("price_cents", ColType::BigInteger),
("currency", ColType::StringWithDefault("EUR".to_string())),
("sku", ColType::StringNull),
("stock", ColType::IntegerWithDefault(0)),
("view_count", ColType::IntegerWithDefault(0)),
("published", ColType::BooleanWithDefault(false)),
("published_at", ColType::TimestampWithTimeZoneNull),
],
&[
("category?", ""),
]
).await
}
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
drop_table(m, "products").await
}
}

View File

@@ -0,0 +1,28 @@
use loco_rs::schema::*;
use sea_orm_migration::prelude::*;
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
create_table(m, "product_images",
&[
("id", ColType::PkAuto),
("image_id", ColType::String),
("position", ColType::IntegerWithDefault(0)),
("alt", ColType::StringNull),
],
&[
("product", ""),
]
).await
}
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
drop_table(m, "product_images").await
}
}

View File

@@ -0,0 +1,26 @@
use loco_rs::schema::*;
use sea_orm_migration::prelude::*;
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
create_table(m, "product_tags",
&[
("id", ColType::PkAuto),
("name", ColType::String),
("slug", ColType::StringUniq),
],
&[
]
).await
}
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
drop_table(m, "product_tags").await
}
}

View File

@@ -0,0 +1,23 @@
use loco_rs::schema::*;
use sea_orm_migration::prelude::*;
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
create_join_table_without_timestamps(m, "product_product_tags",
&[
],
&[
("product", ""),
("product_tag", ""),
]
).await
}
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
drop_table(m, "product_product_tags").await
}
}

View File

@@ -0,0 +1,35 @@
use loco_rs::schema::*;
use sea_orm_migration::prelude::*;
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
create_table(m, "orders",
&[
("id", ColType::PkAuto),
("order_number", ColType::StringUniq),
("email", ColType::String),
("customer_name", ColType::StringNull),
("status", ColType::StringWithDefault("pending".to_string())),
("total_cents", ColType::BigInteger),
("currency", ColType::StringWithDefault("EUR".to_string())),
("address", ColType::StringNull),
("city", ColType::StringNull),
("zip", ColType::StringNull),
("country", ColType::StringNull),
("note", ColType::TextNull),
],
&[
]
).await
}
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
drop_table(m, "orders").await
}
}

View File

@@ -0,0 +1,29 @@
use loco_rs::schema::*;
use sea_orm_migration::prelude::*;
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
create_table(m, "order_items",
&[
("id", ColType::PkAuto),
("product_name", ColType::String),
("unit_price_cents", ColType::BigInteger),
("quantity", ColType::IntegerWithDefault(1)),
],
&[
("order", ""),
("product?", ""),
]
).await
}
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
drop_table(m, "order_items").await
}
}

View File

@@ -0,0 +1,42 @@
use sea_orm_migration::prelude::*;
#[derive(DeriveMigrationName)]
pub struct Migration;
#[derive(DeriveIden)]
enum AudioTrackTags {
Table,
}
#[derive(DeriveIden)]
enum AudioTracks {
Table,
}
#[derive(DeriveIden)]
enum AudioTags {
Table,
}
#[derive(DeriveIden)]
enum AudioAlbums {
Table,
}
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
// Drop child tables before parents to satisfy foreign keys.
m.drop_table(Table::drop().table(AudioTrackTags::Table).if_exists().to_owned())
.await?;
m.drop_table(Table::drop().table(AudioTracks::Table).if_exists().to_owned())
.await?;
m.drop_table(Table::drop().table(AudioTags::Table).if_exists().to_owned())
.await?;
m.drop_table(Table::drop().table(AudioAlbums::Table).if_exists().to_owned())
.await?;
Ok(())
}
async fn down(&self, _m: &SchemaManager) -> Result<(), DbErr> {
// The music domain has been retired; recreating it is out of scope.
Ok(())
}
}

View File

@@ -0,0 +1,29 @@
use sea_orm_migration::prelude::*;
#[derive(DeriveMigrationName)]
pub struct Migration;
#[derive(DeriveIden)]
enum BlogArticles {
Table,
}
#[derive(DeriveIden)]
enum SitePages {
Table,
}
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
m.drop_table(Table::drop().table(BlogArticles::Table).if_exists().to_owned())
.await?;
m.drop_table(Table::drop().table(SitePages::Table).if_exists().to_owned())
.await?;
Ok(())
}
async fn down(&self, _m: &SchemaManager) -> Result<(), DbErr> {
// The blog and static-pages domains have been retired.
Ok(())
}
}