Add most tables
This commit is contained in:
parent
8dae1384af
commit
a60246c95e
159
migration/src/checkouts/m20230603_120800_carts.rs
Normal file
159
migration/src/checkouts/m20230603_120800_carts.rs
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
use sea_orm_migration::prelude::*;
|
||||||
|
|
||||||
|
use crate::sea_orm::Iterable;
|
||||||
|
use crate::*;
|
||||||
|
|
||||||
|
#[derive(DeriveMigrationName)]
|
||||||
|
pub struct Migration;
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl MigrationTrait for Migration {
|
||||||
|
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
create_type!(m, CartType);
|
||||||
|
|
||||||
|
self.create_carts(m).await?;
|
||||||
|
self.create_cart_discounts(m).await?;
|
||||||
|
self.create_cart_gift_cards(m).await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
self.drop_table(m, Cart::Carts).await?;
|
||||||
|
self.drop_table(m, CartDiscount::CartDiscounts).await?;
|
||||||
|
self.drop_table(m, CartGiftCard::CartGiftCards).await?;
|
||||||
|
|
||||||
|
drop_type!(m, CartType);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Migration {
|
||||||
|
/// ```sql
|
||||||
|
/// CREATE TABLE carts
|
||||||
|
/// (
|
||||||
|
/// id uuid NOT NULL,
|
||||||
|
/// email character varying,
|
||||||
|
/// billing_address_id uuid,
|
||||||
|
/// shipping_address_id uuid,
|
||||||
|
/// region_id uuid NOT NULL,
|
||||||
|
/// customer_id uuid,
|
||||||
|
/// payment_id uuid,
|
||||||
|
/// type cart_types DEFAULT 'default'::cart_types NOT NULL,
|
||||||
|
/// completed_at timestamp with time zone,
|
||||||
|
/// created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
/// updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
/// deleted_at timestamp with time zone,
|
||||||
|
/// metadata jsonb,
|
||||||
|
/// idempotency_key character varying,
|
||||||
|
/// context jsonb,
|
||||||
|
/// payment_authorized_at timestamp with time zone,
|
||||||
|
/// sales_channel_id uuid
|
||||||
|
/// );
|
||||||
|
/// ```
|
||||||
|
async fn create_carts(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||||
|
use Cart::*;
|
||||||
|
|
||||||
|
m.build_table(
|
||||||
|
Carts,
|
||||||
|
&mut [
|
||||||
|
Id.col().uuid().not_null().primary_key().default_gen_uuid(),
|
||||||
|
Email.col().string(),
|
||||||
|
BillingAddressId.col().uuid(),
|
||||||
|
ShippingAddressId.col().uuid(),
|
||||||
|
RegionId.col().uuid().not_null(),
|
||||||
|
CustomerId.col().uuid(),
|
||||||
|
PaymentId.col().uuid(),
|
||||||
|
CartType
|
||||||
|
.col()
|
||||||
|
.not_null()
|
||||||
|
.default(crate::types::CartType::Default.to_string())
|
||||||
|
.enumeration(
|
||||||
|
crate::types::CartType::CartTypes,
|
||||||
|
crate::types::CartType::iter().skip(1),
|
||||||
|
),
|
||||||
|
CompletedAt.col().timestamp(),
|
||||||
|
CreatedAt.col().timestamp().not_null().default_now(),
|
||||||
|
UpdatedAt.col().timestamp().not_null().default_now(),
|
||||||
|
DeletedAt.col().timestamp(),
|
||||||
|
Metadata.col().json_binary(),
|
||||||
|
IdempotencyKey.col().uuid(),
|
||||||
|
Context.col().json_binary(),
|
||||||
|
PaymentAuthorizedAt.col().timestamp(),
|
||||||
|
SalesChannelId.col().uuid(),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ```sql
|
||||||
|
/// CREATE TABLE cart_discounts
|
||||||
|
/// (
|
||||||
|
/// cart_id uuid NOT NULL,
|
||||||
|
/// discount_id uuid NOT NULL
|
||||||
|
/// );
|
||||||
|
/// ```
|
||||||
|
async fn create_cart_discounts(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||||
|
use CartDiscount::*;
|
||||||
|
|
||||||
|
m.create_bridge_table(CartDiscounts, CartId, DiscountId)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ```sql
|
||||||
|
/// CREATE TABLE cart_gift_cards
|
||||||
|
/// (
|
||||||
|
/// cart_id uuid NOT NULL,
|
||||||
|
/// gift_card_id uuid NOT NULL
|
||||||
|
/// );
|
||||||
|
/// ```
|
||||||
|
async fn create_cart_gift_cards(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||||
|
use CartGiftCard::*;
|
||||||
|
|
||||||
|
m.create_bridge_table(CartGiftCards, CartId, GiftCardId)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Iden, Debug, Clone, Copy)]
|
||||||
|
pub enum Cart {
|
||||||
|
Carts,
|
||||||
|
Id,
|
||||||
|
Email,
|
||||||
|
BillingAddressId,
|
||||||
|
ShippingAddressId,
|
||||||
|
RegionId,
|
||||||
|
CustomerId,
|
||||||
|
PaymentId,
|
||||||
|
CartType,
|
||||||
|
CompletedAt,
|
||||||
|
CreatedAt,
|
||||||
|
UpdatedAt,
|
||||||
|
DeletedAt,
|
||||||
|
Metadata,
|
||||||
|
IdempotencyKey,
|
||||||
|
Context,
|
||||||
|
PaymentAuthorizedAt,
|
||||||
|
SalesChannelId,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Iden, Debug, Clone, Copy)]
|
||||||
|
pub enum CartDiscount {
|
||||||
|
CartDiscounts,
|
||||||
|
CartId,
|
||||||
|
DiscountId,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Iden, Debug, Clone, Copy)]
|
||||||
|
pub enum CartGiftCard {
|
||||||
|
CartGiftCards,
|
||||||
|
CartId,
|
||||||
|
GiftCardId,
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
mod m20230603_120800_carts;
|
||||||
mod m20230603_120814_checkouts;
|
mod m20230603_120814_checkouts;
|
||||||
mod m20230603_120815_items;
|
mod m20230603_120815_items;
|
||||||
|
|
||||||
@ -9,6 +10,7 @@ pub struct CheckoutsMigrator;
|
|||||||
impl MigratorTrait for CheckoutsMigrator {
|
impl MigratorTrait for CheckoutsMigrator {
|
||||||
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
|
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
|
||||||
vec![
|
vec![
|
||||||
|
Box::new(m20230603_120800_carts::Migration),
|
||||||
Box::new(m20230603_120814_checkouts::Migration),
|
Box::new(m20230603_120814_checkouts::Migration),
|
||||||
Box::new(m20230603_120815_items::Migration),
|
Box::new(m20230603_120815_items::Migration),
|
||||||
]
|
]
|
||||||
|
@ -4,8 +4,6 @@ pub use sea_orm_migration::prelude::*;
|
|||||||
|
|
||||||
pub mod carts;
|
pub mod carts;
|
||||||
pub use carts::*;
|
pub use carts::*;
|
||||||
pub mod discounts;
|
|
||||||
pub use discounts::*;
|
|
||||||
pub mod jobs;
|
pub mod jobs;
|
||||||
pub use jobs::*;
|
pub use jobs::*;
|
||||||
pub mod public;
|
pub mod public;
|
||||||
@ -24,6 +22,11 @@ pub mod notifications;
|
|||||||
pub use notifications::*;
|
pub use notifications::*;
|
||||||
pub mod identity;
|
pub mod identity;
|
||||||
pub use identity::*;
|
pub use identity::*;
|
||||||
|
pub mod stores;
|
||||||
|
pub use stores::*;
|
||||||
|
pub mod marketing;
|
||||||
|
pub use marketing::*;
|
||||||
|
pub mod oauth2;
|
||||||
|
pub use oauth2::*;
|
||||||
pub mod types;
|
pub mod types;
|
||||||
|
|
||||||
pub use types::*;
|
pub use types::*;
|
||||||
|
@ -36,12 +36,13 @@ async fn main() {
|
|||||||
migrate_schema!(cli, Public, PublicMigrator);
|
migrate_schema!(cli, Public, PublicMigrator);
|
||||||
migrate_schema!(cli, Jobs, JobsMigrator);
|
migrate_schema!(cli, Jobs, JobsMigrator);
|
||||||
migrate_schema!(cli, Carts, CartsMigrator);
|
migrate_schema!(cli, Carts, CartsMigrator);
|
||||||
migrate_schema!(cli, Discounts, DiscountsMigrator);
|
migrate_schema!(cli, Marketing, MarketingMigrator);
|
||||||
migrate_schema!(cli, Checkouts, CheckoutsMigrator);
|
migrate_schema!(cli, Checkouts, CheckoutsMigrator);
|
||||||
migrate_schema!(cli, Shipping, ShippingMigrator);
|
migrate_schema!(cli, Shipping, ShippingMigrator);
|
||||||
migrate_schema!(cli, Stocks, StocksMigrator);
|
migrate_schema!(cli, Stocks, StocksMigrator);
|
||||||
migrate_schema!(cli, Identity, IdentityMigrator);
|
migrate_schema!(cli, Identity, IdentityMigrator);
|
||||||
migrate_schema!(cli, Notifications, NotificationsMigrator);
|
migrate_schema!(cli, Notifications, NotificationsMigrator);
|
||||||
|
migrate_schema!(cli, Oauth2, OAuth2Migrator);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn run_cli<M>(cli: &mut Cli, schema: PostgreSQLSchema, migrator: M)
|
pub async fn run_cli<M>(cli: &mut Cli, schema: PostgreSQLSchema, migrator: M)
|
||||||
|
114
migration/src/marketing/m20230603_120810_marketing.rs
Normal file
114
migration/src/marketing/m20230603_120810_marketing.rs
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
use sea_orm_migration::prelude::*;
|
||||||
|
|
||||||
|
use crate::*;
|
||||||
|
|
||||||
|
#[derive(DeriveMigrationName)]
|
||||||
|
pub struct Migration;
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl MigrationTrait for Migration {
|
||||||
|
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
self.create_sales_channels(m).await?;
|
||||||
|
self.create_sales_channel_locations(m).await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
self.drop_table(m, SalesChannel::SalesChannels).await?;
|
||||||
|
self.drop_table(m, SalesChannelLocation::SalesChannelLocations)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Migration {
|
||||||
|
/// ```sql
|
||||||
|
/// CREATE TABLE sales_channels
|
||||||
|
/// (
|
||||||
|
/// id uuid NOT NULL,
|
||||||
|
/// created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
/// updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
/// deleted_at timestamp with time zone,
|
||||||
|
/// name character varying NOT NULL,
|
||||||
|
/// description character varying,
|
||||||
|
/// is_disabled boolean DEFAULT false NOT NULL,
|
||||||
|
/// metadata jsonb
|
||||||
|
/// );
|
||||||
|
/// ```
|
||||||
|
async fn create_sales_channels(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||||
|
use SalesChannel::*;
|
||||||
|
|
||||||
|
m.build_table(
|
||||||
|
SalesChannels,
|
||||||
|
&mut [
|
||||||
|
Id.col().uuid().default_gen_uuid().not_null().primary_key(),
|
||||||
|
CreatedAt.col().timestamp().default_now().not_null(),
|
||||||
|
UpdatedAt.col().timestamp().default_now().not_null(),
|
||||||
|
DeletedAt.col().timestamp(),
|
||||||
|
Name.col().string().not_null(),
|
||||||
|
Description.col().string(),
|
||||||
|
IsDisabled.col().boolean().default(false).not_null(),
|
||||||
|
Metadata.col().json_binary(),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ```sql
|
||||||
|
/// CREATE TABLE sales_channel_locations
|
||||||
|
/// (
|
||||||
|
/// id uuid NOT NULL,
|
||||||
|
/// created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
/// updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
/// sales_channel_id text NOT NULL,
|
||||||
|
/// location_id text NOT NULL,
|
||||||
|
/// deleted_at timestamp with time zone
|
||||||
|
/// );
|
||||||
|
/// ```
|
||||||
|
async fn create_sales_channel_locations(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||||
|
use SalesChannelLocation::*;
|
||||||
|
|
||||||
|
m.build_table(
|
||||||
|
SalesChannelLocations,
|
||||||
|
&mut [
|
||||||
|
Id.col().uuid().default_gen_uuid().not_null().primary_key(),
|
||||||
|
CreatedAt.col().timestamp().default_now().not_null(),
|
||||||
|
UpdatedAt.col().timestamp().default_now().not_null(),
|
||||||
|
SalesChannelId.col().uuid().not_null(),
|
||||||
|
LocationId.col().uuid().not_null(),
|
||||||
|
DeletedAt.col().timestamp(),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Iden, Debug, Clone, Copy)]
|
||||||
|
pub enum SalesChannel {
|
||||||
|
SalesChannels,
|
||||||
|
Id,
|
||||||
|
CreatedAt,
|
||||||
|
UpdatedAt,
|
||||||
|
DeletedAt,
|
||||||
|
Name,
|
||||||
|
Description,
|
||||||
|
IsDisabled,
|
||||||
|
Metadata,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Iden, Debug, Clone, Copy)]
|
||||||
|
pub enum SalesChannelLocation {
|
||||||
|
SalesChannelLocations,
|
||||||
|
Id,
|
||||||
|
CreatedAt,
|
||||||
|
UpdatedAt,
|
||||||
|
SalesChannelId,
|
||||||
|
LocationId,
|
||||||
|
DeletedAt,
|
||||||
|
}
|
@ -10,6 +10,7 @@ impl MigrationTrait for Migration {
|
|||||||
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
||||||
Self::create_gift_carts(m).await?;
|
Self::create_gift_carts(m).await?;
|
||||||
Self::gift_card_transactions(m).await?;
|
Self::gift_card_transactions(m).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -1,14 +1,17 @@
|
|||||||
|
mod m20230603_120810_marketing;
|
||||||
mod m20230603_120814_discounts;
|
mod m20230603_120814_discounts;
|
||||||
mod m20230603_120815_gift_carts;
|
mod m20230603_120815_gift_carts;
|
||||||
|
|
||||||
use sea_orm_migration::{MigrationTrait, MigratorTrait};
|
use sea_orm_migration::{MigrationTrait, MigratorTrait};
|
||||||
|
|
||||||
pub struct DiscountsMigrator;
|
pub struct MarketingMigrator;
|
||||||
|
|
||||||
|
/// TODO
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl MigratorTrait for DiscountsMigrator {
|
impl MigratorTrait for MarketingMigrator {
|
||||||
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
|
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
|
||||||
vec![
|
vec![
|
||||||
|
Box::new(m20230603_120810_marketing::Migration),
|
||||||
Box::new(m20230603_120814_discounts::Migration),
|
Box::new(m20230603_120814_discounts::Migration),
|
||||||
Box::new(m20230603_120815_gift_carts::Migration),
|
Box::new(m20230603_120815_gift_carts::Migration),
|
||||||
]
|
]
|
152
migration/src/oauth2/m20230603_120810_oauth2.rs
Normal file
152
migration/src/oauth2/m20230603_120810_oauth2.rs
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
use sea_orm_migration::prelude::*;
|
||||||
|
|
||||||
|
use crate::*;
|
||||||
|
|
||||||
|
#[derive(DeriveMigrationName)]
|
||||||
|
pub struct Migration;
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl MigrationTrait for Migration {
|
||||||
|
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
self.create_oauth(m).await?;
|
||||||
|
self.create_publishable_api_keys(m).await?;
|
||||||
|
self.create_publishable_api_key_sales_channels(m).await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
self.drop_table(m, Oauth2::Oauth).await?;
|
||||||
|
self.drop_table(m, PublishableApiKey::PublishableApiKeys)
|
||||||
|
.await?;
|
||||||
|
self.drop_table(
|
||||||
|
m,
|
||||||
|
PublishableApiKeySalesChannel::PublishableApiKeySalesChannels,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Migration {
|
||||||
|
/// ```sql
|
||||||
|
/// CREATE TABLE oauth
|
||||||
|
/// (
|
||||||
|
/// id uuid NOT NULL,
|
||||||
|
/// display_name character varying NOT NULL,
|
||||||
|
/// application_name character varying NOT NULL,
|
||||||
|
/// install_url character varying,
|
||||||
|
/// uninstall_url character varying,
|
||||||
|
/// data jsonb
|
||||||
|
/// );
|
||||||
|
/// ```
|
||||||
|
async fn create_oauth(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||||
|
use Oauth2::*;
|
||||||
|
|
||||||
|
m.build_table(
|
||||||
|
Oauth,
|
||||||
|
&mut [
|
||||||
|
Id.col().uuid().not_null().primary_key().default_gen_uuid(),
|
||||||
|
DisplayName.col().string().not_null(),
|
||||||
|
ApplicationName.col().string().not_null(),
|
||||||
|
InstallUrl.col().string(),
|
||||||
|
UninstallUrl.col().string(),
|
||||||
|
Data.col().json_binary(),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ```sql
|
||||||
|
/// CREATE TABLE publishable_api_keys
|
||||||
|
/// (
|
||||||
|
/// id uuid NOT NULL,
|
||||||
|
/// created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
/// updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
/// created_by character varying,
|
||||||
|
/// revoked_by character varying,
|
||||||
|
/// revoked_at timestamp with time zone,
|
||||||
|
/// title character varying NOT NULL
|
||||||
|
/// );
|
||||||
|
/// ```
|
||||||
|
async fn create_publishable_api_keys(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||||
|
use PublishableApiKey::*;
|
||||||
|
|
||||||
|
m.build_table(
|
||||||
|
PublishableApiKeys,
|
||||||
|
&mut [
|
||||||
|
Id.col()
|
||||||
|
.uuid()
|
||||||
|
.primary_key()
|
||||||
|
.uuid()
|
||||||
|
.not_null()
|
||||||
|
.default_gen_uuid(),
|
||||||
|
CreatedAt.col().timestamp().not_null().default_now(),
|
||||||
|
UpdatedAt.col().timestamp().not_null().default_now(),
|
||||||
|
CreatedBy.col().uuid(),
|
||||||
|
RevokedBy.col().uuid(),
|
||||||
|
RevokedAt.col().timestamp(),
|
||||||
|
Title.col().string().not_null(),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ```sql
|
||||||
|
/// CREATE TABLE publishable_api_key_sales_channels
|
||||||
|
/// (
|
||||||
|
/// sales_channel_id uuid NOT NULL,
|
||||||
|
/// publishable_key_id uuid NOT NULL
|
||||||
|
/// );
|
||||||
|
/// ```
|
||||||
|
async fn create_publishable_api_key_sales_channels(
|
||||||
|
&self,
|
||||||
|
m: &SchemaManager<'_>,
|
||||||
|
) -> Result<(), DbErr> {
|
||||||
|
use PublishableApiKeySalesChannel::*;
|
||||||
|
|
||||||
|
m.create_bridge_table(
|
||||||
|
PublishableApiKeySalesChannels,
|
||||||
|
SalesChannelId,
|
||||||
|
PublishableKeyId,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Iden, Copy, Clone, Debug)]
|
||||||
|
pub enum Oauth2 {
|
||||||
|
Oauth,
|
||||||
|
Id,
|
||||||
|
DisplayName,
|
||||||
|
ApplicationName,
|
||||||
|
InstallUrl,
|
||||||
|
UninstallUrl,
|
||||||
|
Data,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Iden, Copy, Clone, Debug)]
|
||||||
|
pub enum PublishableApiKey {
|
||||||
|
PublishableApiKeys,
|
||||||
|
Id,
|
||||||
|
CreatedAt,
|
||||||
|
UpdatedAt,
|
||||||
|
CreatedBy,
|
||||||
|
RevokedBy,
|
||||||
|
RevokedAt,
|
||||||
|
Title,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Iden, Copy, Clone, Debug)]
|
||||||
|
pub enum PublishableApiKeySalesChannel {
|
||||||
|
PublishableApiKeySalesChannels,
|
||||||
|
SalesChannelId,
|
||||||
|
PublishableKeyId,
|
||||||
|
}
|
12
migration/src/oauth2/mod.rs
Normal file
12
migration/src/oauth2/mod.rs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
mod m20230603_120810_oauth2;
|
||||||
|
|
||||||
|
use sea_orm_migration::{MigrationTrait, MigratorTrait};
|
||||||
|
|
||||||
|
pub struct OAuth2Migrator;
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl MigratorTrait for OAuth2Migrator {
|
||||||
|
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
|
||||||
|
vec![Box::new(m20230603_120810_oauth2::Migration)]
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,6 @@ use sea_orm_migration::{MigrationTrait, MigratorTrait};
|
|||||||
mod m20230603_102634_types;
|
mod m20230603_102634_types;
|
||||||
mod m20230603_120814_addresses;
|
mod m20230603_120814_addresses;
|
||||||
mod m20230603_120815_claims;
|
mod m20230603_120815_claims;
|
||||||
mod m20230603_120816_geolocation;
|
|
||||||
|
|
||||||
pub struct PublicMigrator;
|
pub struct PublicMigrator;
|
||||||
|
|
||||||
@ -14,7 +13,6 @@ impl MigratorTrait for PublicMigrator {
|
|||||||
Box::new(m20230603_102634_types::Migration),
|
Box::new(m20230603_102634_types::Migration),
|
||||||
Box::new(m20230603_120814_addresses::Migration),
|
Box::new(m20230603_120814_addresses::Migration),
|
||||||
Box::new(m20230603_120815_claims::Migration),
|
Box::new(m20230603_120815_claims::Migration),
|
||||||
Box::new(m20230603_120816_geolocation::Migration),
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,13 @@ pub enum PostgreSQLSchema {
|
|||||||
Public,
|
Public,
|
||||||
Jobs,
|
Jobs,
|
||||||
Carts,
|
Carts,
|
||||||
Discounts,
|
|
||||||
Checkouts,
|
Checkouts,
|
||||||
Shipping,
|
Shipping,
|
||||||
Stocks,
|
Stocks,
|
||||||
Identity,
|
Identity,
|
||||||
Notifications,
|
Notifications,
|
||||||
|
Oauth2,
|
||||||
|
Marketing,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PostgreSQLSchema {
|
impl PostgreSQLSchema {
|
||||||
@ -21,12 +22,13 @@ impl PostgreSQLSchema {
|
|||||||
PostgreSQLSchema::Public => "public",
|
PostgreSQLSchema::Public => "public",
|
||||||
PostgreSQLSchema::Jobs => "jobs",
|
PostgreSQLSchema::Jobs => "jobs",
|
||||||
PostgreSQLSchema::Carts => "carts",
|
PostgreSQLSchema::Carts => "carts",
|
||||||
PostgreSQLSchema::Discounts => "discounts",
|
|
||||||
PostgreSQLSchema::Checkouts => "checkouts",
|
PostgreSQLSchema::Checkouts => "checkouts",
|
||||||
PostgreSQLSchema::Shipping => "shipping",
|
PostgreSQLSchema::Shipping => "shipping",
|
||||||
PostgreSQLSchema::Stocks => "stocks",
|
PostgreSQLSchema::Stocks => "stocks",
|
||||||
PostgreSQLSchema::Identity => "identity",
|
PostgreSQLSchema::Identity => "identity",
|
||||||
PostgreSQLSchema::Notifications => "notifications",
|
PostgreSQLSchema::Notifications => "notifications",
|
||||||
|
PostgreSQLSchema::Oauth2 => "oauth2",
|
||||||
|
PostgreSQLSchema::Marketing => "marketing",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,16 +110,54 @@ impl CreateBridgeTable for SchemaManager<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub trait DefaultNow {
|
||||||
|
fn default_now(&mut self) -> &mut Self;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DefaultNow for ColumnDef {
|
||||||
|
fn default_now(&mut self) -> &mut Self {
|
||||||
|
self.default(SimpleExpr::Custom("now()".into()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait DefaultGenUuid {
|
||||||
|
fn default_gen_uuid(&mut self) -> &mut Self;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DefaultGenUuid for ColumnDef {
|
||||||
|
fn default_gen_uuid(&mut self) -> &mut Self {
|
||||||
|
self.default(SimpleExpr::Custom("public.uuid_generate_v4()".into()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait CreateTableExt {
|
pub trait CreateTableExt {
|
||||||
async fn build_table<Enum>(&self, table: Enum, fields: Vec<ColumnDef>) -> Result<(), DbErr>
|
async fn build_table<'c, Enum>(
|
||||||
|
&self,
|
||||||
|
table: Enum,
|
||||||
|
fields: &'c mut [&'c mut ColumnDef],
|
||||||
|
) -> Result<(), DbErr>
|
||||||
where
|
where
|
||||||
Enum: IntoIden + Copy + 'static + Sync + Send;
|
Enum: IntoIden + Copy + 'static + Sync + Send;
|
||||||
|
|
||||||
|
async fn build_table_with<'c, Enum, F>(
|
||||||
|
&self,
|
||||||
|
table: Enum,
|
||||||
|
fields: &'c mut [&'c mut ColumnDef],
|
||||||
|
f: F,
|
||||||
|
) -> Result<(), DbErr>
|
||||||
|
where
|
||||||
|
Enum: IntoIden + Copy + 'static + Sync + Send,
|
||||||
|
F: FnOnce(&mut TableCreateStatement) + Send;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl CreateTableExt for SchemaManager<'_> {
|
impl CreateTableExt for SchemaManager<'_> {
|
||||||
async fn build_table<Enum>(&self, table: Enum, mut fields: Vec<ColumnDef>) -> Result<(), DbErr>
|
async fn build_table<'c, Enum>(
|
||||||
|
&self,
|
||||||
|
table: Enum,
|
||||||
|
fields: &'c mut [&'c mut ColumnDef],
|
||||||
|
) -> Result<(), DbErr>
|
||||||
where
|
where
|
||||||
Enum: IntoIden + Copy + 'static + Sync + Send,
|
Enum: IntoIden + Copy + 'static + Sync + Send,
|
||||||
{
|
{
|
||||||
@ -131,6 +169,26 @@ impl CreateTableExt for SchemaManager<'_> {
|
|||||||
self.create_table(t).await?;
|
self.create_table(t).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn build_table_with<'c, Enum, F>(
|
||||||
|
&self,
|
||||||
|
table: Enum,
|
||||||
|
fields: &'c mut [&'c mut ColumnDef],
|
||||||
|
f: F,
|
||||||
|
) -> Result<(), DbErr>
|
||||||
|
where
|
||||||
|
Enum: IntoIden + Copy + 'static + Sync + Send,
|
||||||
|
F: FnOnce(&mut TableCreateStatement) + Send,
|
||||||
|
{
|
||||||
|
let mut t = Table::create();
|
||||||
|
t.table(table);
|
||||||
|
fields.iter_mut().for_each(|col| {
|
||||||
|
t.col(col);
|
||||||
|
});
|
||||||
|
f(&mut t);
|
||||||
|
self.create_table(t).await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_pk2_name<T1: IntoIden, C1: IntoIden, C2: IntoIden>(t1: T1, c1: C1, c2: C2) -> String {
|
pub fn to_pk2_name<T1: IntoIden, C1: IntoIden, C2: IntoIden>(t1: T1, c1: C1, c2: C2) -> String {
|
||||||
|
@ -8,10 +8,10 @@ pub struct Migration;
|
|||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl MigrationTrait for Migration {
|
impl MigrationTrait for Migration {
|
||||||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
||||||
Self::create_countries(manager).await?;
|
Self::create_countries(m).await?;
|
||||||
Self::create_currencies(manager).await?;
|
Self::create_currencies(m).await?;
|
||||||
Self::create_regions(manager).await?;
|
Self::create_regions(m).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
244
migration/src/stores/m20230603_120810_store_ext.rs
Normal file
244
migration/src/stores/m20230603_120810_store_ext.rs
Normal file
@ -0,0 +1,244 @@
|
|||||||
|
use sea_orm_migration::prelude::*;
|
||||||
|
|
||||||
|
use crate::*;
|
||||||
|
|
||||||
|
#[derive(DeriveMigrationName)]
|
||||||
|
pub struct Migration;
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl MigrationTrait for Migration {
|
||||||
|
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
self.create_stores(m).await?;
|
||||||
|
self.create_store_currencies(m).await?;
|
||||||
|
self.create_tax_providers(m).await?;
|
||||||
|
self.create_tax_rates(m).await?;
|
||||||
|
self.create_region_fulfillment_providers(m).await?;
|
||||||
|
self.create_region_payment_providers(m).await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
self.drop_table(m, Store::Stores).await?;
|
||||||
|
self.drop_table(m, StoreCurrency::StoreCurrencies).await?;
|
||||||
|
self.drop_table(m, TaxProvider::TaxProviders).await?;
|
||||||
|
self.drop_table(m, TaxRate::TaxRates).await?;
|
||||||
|
self.drop_table(m, RegionFulfillmentProvider::RegionFulfillmentProviders)
|
||||||
|
.await?;
|
||||||
|
self.drop_table(m, RegionPaymentProvider::RegionPaymentProviders)
|
||||||
|
.await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Migration {
|
||||||
|
/// ```sql
|
||||||
|
/// CREATE TABLE stores
|
||||||
|
/// (
|
||||||
|
/// id uuid NOT NULL,
|
||||||
|
/// name character varying DEFAULT 'Bazaar'::character varying NOT NULL,
|
||||||
|
/// default_currency_code character varying DEFAULT 'pln'::character varying NOT NULL,
|
||||||
|
/// swap_link_template character varying,
|
||||||
|
/// created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
/// updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
/// metadata jsonb,
|
||||||
|
/// payment_link_template character varying,
|
||||||
|
/// invite_link_template character varying,
|
||||||
|
/// default_sales_channel_id uuid,
|
||||||
|
/// default_location_id uuid
|
||||||
|
/// );
|
||||||
|
/// ```
|
||||||
|
async fn create_stores(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||||
|
use Store::*;
|
||||||
|
|
||||||
|
m.build_table(
|
||||||
|
Stores,
|
||||||
|
&mut [
|
||||||
|
Id.col().uuid().not_null().primary_key().default_gen_uuid(),
|
||||||
|
Name.col().string().default("Bazzar".to_string()).not_null(),
|
||||||
|
DefaultCurrencyCode.col().string().default("pln").not_null(),
|
||||||
|
SwapLinkTemplate.col().string(),
|
||||||
|
CreatedAt.col().timestamp().not_null().default_now(),
|
||||||
|
UpdatedAt.col().timestamp().not_null().default_now(),
|
||||||
|
Metadata.col().json_binary(),
|
||||||
|
PaymentLinkTemplate.col().string(),
|
||||||
|
InviteLinkTemplate.col().string(),
|
||||||
|
DefaultSalesChannelId.col().uuid(),
|
||||||
|
DefaultLocationId.col().uuid(),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ```sql
|
||||||
|
/// CREATE TABLE store_currencies
|
||||||
|
/// (
|
||||||
|
/// store_id uuid NOT NULL,
|
||||||
|
/// currency_code character varying NOT NULL
|
||||||
|
/// );
|
||||||
|
/// ```
|
||||||
|
async fn create_store_currencies(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||||
|
use StoreCurrency::*;
|
||||||
|
|
||||||
|
m.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(StoreCurrencies)
|
||||||
|
.col(StoreId.col().uuid().not_null())
|
||||||
|
.col(CurrencyCode.col().string().not_null())
|
||||||
|
.primary_key(&mut m.bridge_primary_key(StoreCurrencies, StoreId, CurrencyCode))
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ```sql
|
||||||
|
/// CREATE TABLE tax_providers
|
||||||
|
/// (
|
||||||
|
/// id uuid NOT NULL,
|
||||||
|
/// is_installed boolean DEFAULT true NOT NULL
|
||||||
|
/// );
|
||||||
|
/// ```
|
||||||
|
async fn create_tax_providers(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||||
|
use TaxProvider::*;
|
||||||
|
|
||||||
|
m.build_table(
|
||||||
|
TaxProviders,
|
||||||
|
&mut [
|
||||||
|
Id.col().uuid().not_null().default_gen_uuid().primary_key(),
|
||||||
|
IsInstalled.col().boolean().default(true).not_null(),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ```sql
|
||||||
|
/// CREATE TABLE tax_rates
|
||||||
|
/// (
|
||||||
|
/// id uuid NOT NULL,
|
||||||
|
/// rate real,
|
||||||
|
/// code character varying,
|
||||||
|
/// name character varying NOT NULL,
|
||||||
|
/// region_id uuid NOT NULL,
|
||||||
|
/// created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
/// updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
/// metadata jsonb
|
||||||
|
/// );
|
||||||
|
/// ```
|
||||||
|
async fn create_tax_rates(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||||
|
use TaxRate::*;
|
||||||
|
|
||||||
|
m.build_table(
|
||||||
|
TaxRates,
|
||||||
|
&mut [
|
||||||
|
Id.col().uuid().primary_key().default_gen_uuid(),
|
||||||
|
Rate.col().double(),
|
||||||
|
Code.col().string(),
|
||||||
|
Name.col().string().not_null(),
|
||||||
|
RegionId.col().uuid().not_null(),
|
||||||
|
CreatedAt.col().timestamp().not_null().default_now(),
|
||||||
|
UpdatedAt.col().timestamp().not_null().default_now(),
|
||||||
|
Metadata.col().json_binary(),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ```sql
|
||||||
|
/// CREATE TABLE region_fulfillment_providers
|
||||||
|
/// (
|
||||||
|
/// region_id uuid NOT NULL,
|
||||||
|
/// provider_id uuid NOT NULL
|
||||||
|
/// );
|
||||||
|
/// ```
|
||||||
|
async fn create_region_fulfillment_providers(
|
||||||
|
&self,
|
||||||
|
m: &SchemaManager<'_>,
|
||||||
|
) -> Result<(), DbErr> {
|
||||||
|
use RegionFulfillmentProvider::*;
|
||||||
|
|
||||||
|
m.create_bridge_table(RegionFulfillmentProviders, RegionId, ProviderId)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ```sql
|
||||||
|
/// CREATE TABLE region_payment_providers
|
||||||
|
/// (
|
||||||
|
/// region_id uuid NOT NULL,
|
||||||
|
/// provider_id uuid NOT NULL
|
||||||
|
/// );
|
||||||
|
/// ```
|
||||||
|
async fn create_region_payment_providers(&self, m: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||||
|
use RegionPaymentProvider::*;
|
||||||
|
|
||||||
|
m.create_bridge_table(RegionPaymentProviders, RegionId, ProviderId)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Iden, Clone, Copy)]
|
||||||
|
pub enum Store {
|
||||||
|
Stores,
|
||||||
|
Id,
|
||||||
|
Name,
|
||||||
|
DefaultCurrencyCode,
|
||||||
|
SwapLinkTemplate,
|
||||||
|
CreatedAt,
|
||||||
|
UpdatedAt,
|
||||||
|
Metadata,
|
||||||
|
PaymentLinkTemplate,
|
||||||
|
InviteLinkTemplate,
|
||||||
|
DefaultSalesChannelId,
|
||||||
|
DefaultLocationId,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Iden, Clone, Copy)]
|
||||||
|
pub enum StoreCurrency {
|
||||||
|
StoreCurrencies,
|
||||||
|
StoreId,
|
||||||
|
CurrencyCode,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Iden, Clone, Copy)]
|
||||||
|
pub enum TaxProvider {
|
||||||
|
TaxProviders,
|
||||||
|
Id,
|
||||||
|
IsInstalled,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Iden, Clone, Copy)]
|
||||||
|
pub enum TaxRate {
|
||||||
|
TaxRates,
|
||||||
|
Id,
|
||||||
|
Rate,
|
||||||
|
Code,
|
||||||
|
Name,
|
||||||
|
RegionId,
|
||||||
|
CreatedAt,
|
||||||
|
UpdatedAt,
|
||||||
|
Metadata,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Iden, Clone, Copy)]
|
||||||
|
pub enum RegionFulfillmentProvider {
|
||||||
|
RegionFulfillmentProviders,
|
||||||
|
RegionId,
|
||||||
|
ProviderId,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Iden, Clone, Copy)]
|
||||||
|
pub enum RegionPaymentProvider {
|
||||||
|
RegionPaymentProviders,
|
||||||
|
RegionId,
|
||||||
|
ProviderId,
|
||||||
|
}
|
16
migration/src/stores/mod.rs
Normal file
16
migration/src/stores/mod.rs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
mod m20230603_120810_geolocation;
|
||||||
|
mod m20230603_120810_store_ext;
|
||||||
|
|
||||||
|
use sea_orm_migration::{MigrationTrait, MigratorTrait};
|
||||||
|
|
||||||
|
pub struct StoresMigrator;
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl MigratorTrait for StoresMigrator {
|
||||||
|
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
|
||||||
|
vec![
|
||||||
|
Box::new(m20230603_120810_geolocation::Migration),
|
||||||
|
Box::new(m20230603_120810_store_ext::Migration),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -13,14 +13,6 @@ CREATE TYPE payment_collection_types AS ENUM (
|
|||||||
'order_edit'
|
'order_edit'
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TYPE cart_types AS ENUM (
|
|
||||||
'default',
|
|
||||||
'swap',
|
|
||||||
'draft_order',
|
|
||||||
'payment_link',
|
|
||||||
'claim'
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TYPE claim_item_reasons AS ENUM (
|
CREATE TYPE claim_item_reasons AS ENUM (
|
||||||
'missing_item',
|
'missing_item',
|
||||||
'wrong_item',
|
'wrong_item',
|
||||||
@ -198,32 +190,6 @@ CREATE TYPE swap_payment_statuses AS ENUM (
|
|||||||
'requires_action'
|
'requires_action'
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TYPE user_roles AS ENUM (
|
|
||||||
'admin',
|
|
||||||
'member',
|
|
||||||
'developer'
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE addresses
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
customer_id uuid,
|
|
||||||
company character varying,
|
|
||||||
first_name character varying,
|
|
||||||
last_name character varying,
|
|
||||||
address_1 character varying,
|
|
||||||
address_2 character varying,
|
|
||||||
city character varying,
|
|
||||||
country_code character varying,
|
|
||||||
province character varying,
|
|
||||||
postal_code character varying,
|
|
||||||
phone character varying,
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
deleted_at timestamp with time zone,
|
|
||||||
metadata jsonb
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE analytics_configs
|
CREATE TABLE analytics_configs
|
||||||
(
|
(
|
||||||
id uuid NOT NULL,
|
id uuid NOT NULL,
|
||||||
@ -254,39 +220,6 @@ CREATE TABLE batch_jobs
|
|||||||
deleted_at timestamp with time zone
|
deleted_at timestamp with time zone
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE carts
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
email character varying,
|
|
||||||
billing_address_id uuid,
|
|
||||||
shipping_address_id uuid,
|
|
||||||
region_id uuid NOT NULL,
|
|
||||||
customer_id uuid,
|
|
||||||
payment_id uuid,
|
|
||||||
type cart_types DEFAULT 'default'::cart_types NOT NULL,
|
|
||||||
completed_at timestamp with time zone,
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
deleted_at timestamp with time zone,
|
|
||||||
metadata jsonb,
|
|
||||||
idempotency_key character varying,
|
|
||||||
context jsonb,
|
|
||||||
payment_authorized_at timestamp with time zone,
|
|
||||||
sales_channel_id uuid
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE cart_discounts
|
|
||||||
(
|
|
||||||
cart_id uuid NOT NULL,
|
|
||||||
discount_id uuid NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE cart_gift_cards
|
|
||||||
(
|
|
||||||
cart_id uuid NOT NULL,
|
|
||||||
gift_card_id uuid NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE claim_images
|
CREATE TABLE claim_images
|
||||||
(
|
(
|
||||||
id uuid NOT NULL,
|
id uuid NOT NULL,
|
||||||
@ -347,143 +280,6 @@ CREATE TABLE claim_tags
|
|||||||
metadata jsonb
|
metadata jsonb
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE regions
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
name character varying NOT NULL,
|
|
||||||
currency_code character varying NOT NULL,
|
|
||||||
tax_rate real NOT NULL,
|
|
||||||
tax_code character varying,
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
deleted_at timestamp with time zone,
|
|
||||||
metadata jsonb,
|
|
||||||
gift_cards_taxable boolean DEFAULT true NOT NULL,
|
|
||||||
automatic_taxes boolean DEFAULT true NOT NULL,
|
|
||||||
tax_provider_id uuid
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE countries
|
|
||||||
(
|
|
||||||
id sequence NOT NULL,
|
|
||||||
iso_2 character varying NOT NULL,
|
|
||||||
iso_3 character varying NOT NULL,
|
|
||||||
num_code integer NOT NULL,
|
|
||||||
name character varying NOT NULL,
|
|
||||||
display_name character varying NOT NULL,
|
|
||||||
region_id uuid
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE currencies
|
|
||||||
(
|
|
||||||
code character varying NOT NULL,
|
|
||||||
symbol character varying NOT NULL,
|
|
||||||
symbol_native character varying NOT NULL,
|
|
||||||
name character varying NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE discounts
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
code character varying NOT NULL,
|
|
||||||
is_dynamic boolean NOT NULL,
|
|
||||||
rule_id uuid,
|
|
||||||
is_disabled boolean NOT NULL,
|
|
||||||
parent_discount_id uuid,
|
|
||||||
starts_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
||||||
ends_at timestamp with time zone,
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
deleted_at timestamp with time zone,
|
|
||||||
metadata jsonb,
|
|
||||||
usage_limit integer,
|
|
||||||
usage_count integer DEFAULT 0 NOT NULL,
|
|
||||||
valid_duration character varying
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE discount_conditions
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
type discount_condition_types NOT NULL,
|
|
||||||
operator discount_condition_operators NOT NULL,
|
|
||||||
discount_rule_id uuid NOT NULL,
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
deleted_at timestamp with time zone,
|
|
||||||
metadata jsonb
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE discount_condition_customer_groups
|
|
||||||
(
|
|
||||||
customer_group_id uuid NOT NULL,
|
|
||||||
condition_id uuid NOT NULL,
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
metadata jsonb
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE discount_condition_products
|
|
||||||
(
|
|
||||||
product_id uuid NOT NULL,
|
|
||||||
condition_id uuid NOT NULL,
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
metadata jsonb
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE discount_condition_product_collections
|
|
||||||
(
|
|
||||||
product_collection_id uuid NOT NULL,
|
|
||||||
condition_id uuid NOT NULL,
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
metadata jsonb
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE discount_condition_product_tags
|
|
||||||
(
|
|
||||||
product_tag_id uuid NOT NULL,
|
|
||||||
condition_id uuid NOT NULL,
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
metadata jsonb
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE discount_condition_product_types
|
|
||||||
(
|
|
||||||
product_type_id uuid NOT NULL,
|
|
||||||
condition_id uuid NOT NULL,
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
metadata jsonb
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE discount_regions
|
|
||||||
(
|
|
||||||
discount_id uuid NOT NULL,
|
|
||||||
region_id uuid NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE discount_rules
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
description character varying,
|
|
||||||
type discount_rule_types NOT NULL,
|
|
||||||
value integer NOT NULL,
|
|
||||||
allocation discount_rule_allocations,
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
deleted_at timestamp with time zone,
|
|
||||||
metadata jsonb
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE discount_rule_products
|
|
||||||
(
|
|
||||||
discount_rule_id uuid NOT NULL,
|
|
||||||
product_id uuid NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE orders
|
CREATE TABLE orders
|
||||||
(
|
(
|
||||||
id uuid NOT NULL,
|
id uuid NOT NULL,
|
||||||
@ -624,34 +420,6 @@ CREATE TABLE payment_sessions
|
|||||||
is_initiated boolean DEFAULT false NOT NULL
|
is_initiated boolean DEFAULT false NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE gift_cards
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
code character varying NOT NULL,
|
|
||||||
value integer NOT NULL,
|
|
||||||
balance integer NOT NULL,
|
|
||||||
region_id uuid NOT NULL,
|
|
||||||
order_id uuid,
|
|
||||||
is_disabled boolean DEFAULT false NOT NULL,
|
|
||||||
ends_at timestamp with time zone,
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
deleted_at timestamp with time zone,
|
|
||||||
metadata jsonb,
|
|
||||||
tax_rate real
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE gift_card_transactions
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
gift_card_id uuid NOT NULL,
|
|
||||||
order_id uuid NOT NULL,
|
|
||||||
amount integer NOT NULL,
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
is_taxable boolean,
|
|
||||||
tax_rate real
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE line_items
|
CREATE TABLE line_items
|
||||||
(
|
(
|
||||||
id uuid NOT NULL,
|
id uuid NOT NULL,
|
||||||
@ -800,125 +568,6 @@ CREATE TABLE notes
|
|||||||
metadata jsonb
|
metadata jsonb
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE oauth
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
display_name character varying NOT NULL,
|
|
||||||
application_name character varying NOT NULL,
|
|
||||||
install_url character varying,
|
|
||||||
uninstall_url character varying,
|
|
||||||
data jsonb
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE publishable_api_keys
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
created_by character varying,
|
|
||||||
revoked_by character varying,
|
|
||||||
revoked_at timestamp with time zone,
|
|
||||||
title character varying NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE publishable_api_key_sales_channels
|
|
||||||
(
|
|
||||||
sales_channel_id uuid NOT NULL,
|
|
||||||
publishable_key_id uuid NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE refunds
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
order_id uuid,
|
|
||||||
amount integer NOT NULL,
|
|
||||||
note character varying,
|
|
||||||
reason refund_reasons NOT NULL,
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
metadata jsonb,
|
|
||||||
idempotency_key character varying,
|
|
||||||
payment_id uuid
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE region_fulfillment_providers
|
|
||||||
(
|
|
||||||
region_id uuid NOT NULL,
|
|
||||||
provider_id uuid NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE region_payment_providers
|
|
||||||
(
|
|
||||||
region_id uuid NOT NULL,
|
|
||||||
provider_id uuid NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE returns
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
status return_statuses DEFAULT 'requested'::return_statuses NOT NULL,
|
|
||||||
swap_id uuid,
|
|
||||||
order_id uuid,
|
|
||||||
shipping_data jsonb,
|
|
||||||
refund_amount integer NOT NULL,
|
|
||||||
received_at timestamp with time zone,
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
metadata jsonb,
|
|
||||||
idempotency_key character varying,
|
|
||||||
claim_order_id uuid,
|
|
||||||
no_notification boolean,
|
|
||||||
location_id uuid
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE return_items
|
|
||||||
(
|
|
||||||
return_id uuid NOT NULL,
|
|
||||||
item_id uuid NOT NULL,
|
|
||||||
quantity integer NOT NULL,
|
|
||||||
is_requested boolean DEFAULT true NOT NULL,
|
|
||||||
requested_quantity integer,
|
|
||||||
received_quantity integer,
|
|
||||||
metadata jsonb,
|
|
||||||
reason_id uuid,
|
|
||||||
note character varying
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE return_reasons
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
value character varying NOT NULL,
|
|
||||||
label character varying NOT NULL,
|
|
||||||
description character varying,
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
deleted_at timestamp with time zone,
|
|
||||||
metadata jsonb,
|
|
||||||
parent_return_reason_id uuid
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE sales_channels
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
deleted_at timestamp with time zone,
|
|
||||||
name character varying NOT NULL,
|
|
||||||
description character varying,
|
|
||||||
is_disabled boolean DEFAULT false NOT NULL,
|
|
||||||
metadata jsonb
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE sales_channel_locations
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
sales_channel_id text NOT NULL,
|
|
||||||
location_id text NOT NULL,
|
|
||||||
deleted_at timestamp with time zone
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE staged_jobs
|
CREATE TABLE staged_jobs
|
||||||
(
|
(
|
||||||
id uuid NOT NULL,
|
id uuid NOT NULL,
|
||||||
@ -927,27 +576,6 @@ CREATE TABLE staged_jobs
|
|||||||
options jsonb DEFAULT '{}'::jsonb NOT NULL
|
options jsonb DEFAULT '{}'::jsonb NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE stores
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
name character varying DEFAULT 'Bazaar'::character varying NOT NULL,
|
|
||||||
default_currency_code character varying DEFAULT 'pln'::character varying NOT NULL,
|
|
||||||
swap_link_template character varying,
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
metadata jsonb,
|
|
||||||
payment_link_template character varying,
|
|
||||||
invite_link_template character varying,
|
|
||||||
default_sales_channel_id uuid,
|
|
||||||
default_location_id uuid
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE store_currencies
|
|
||||||
(
|
|
||||||
store_id uuid NOT NULL,
|
|
||||||
currency_code character varying NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE swaps
|
CREATE TABLE swaps
|
||||||
(
|
(
|
||||||
id uuid NOT NULL,
|
id uuid NOT NULL,
|
||||||
@ -967,36 +595,3 @@ CREATE TABLE swaps
|
|||||||
canceled_at timestamp with time zone,
|
canceled_at timestamp with time zone,
|
||||||
allow_backorder boolean DEFAULT false NOT NULL
|
allow_backorder boolean DEFAULT false NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE tax_providers
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
is_installed boolean DEFAULT true NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE tax_rates
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
rate real,
|
|
||||||
code character varying,
|
|
||||||
name character varying NOT NULL,
|
|
||||||
region_id uuid NOT NULL,
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
metadata jsonb
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE users
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
email character varying NOT NULL,
|
|
||||||
first_name character varying,
|
|
||||||
last_name character varying,
|
|
||||||
password_hash character varying,
|
|
||||||
api_token character varying,
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
deleted_at timestamp with time zone,
|
|
||||||
metadata jsonb,
|
|
||||||
role user_roles DEFAULT 'member'::user_roles
|
|
||||||
);
|
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
CREATE TABLE customers
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
email character varying NOT NULL,
|
|
||||||
first_name character varying,
|
|
||||||
last_name character varying,
|
|
||||||
billing_address_id uuid,
|
|
||||||
password_hash character varying,
|
|
||||||
phone character varying,
|
|
||||||
has_account boolean DEFAULT false NOT NULL,
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
deleted_at timestamp with time zone,
|
|
||||||
metadata jsonb
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE customer_groups
|
|
||||||
(
|
|
||||||
id uuid NOT NULL,
|
|
||||||
name character varying NOT NULL,
|
|
||||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
deleted_at timestamp with time zone,
|
|
||||||
metadata jsonb
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE customer_group_customers
|
|
||||||
(
|
|
||||||
customer_group_id uuid NOT NULL,
|
|
||||||
customer_id uuid NOT NULL
|
|
||||||
);
|
|
76
migrations/20230603073520_identity.sql
Normal file
76
migrations/20230603073520_identity.sql
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
CREATE TABLE customers
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
email character varying NOT NULL,
|
||||||
|
first_name character varying,
|
||||||
|
last_name character varying,
|
||||||
|
billing_address_id uuid,
|
||||||
|
password_hash character varying,
|
||||||
|
phone character varying,
|
||||||
|
has_account boolean DEFAULT false NOT NULL,
|
||||||
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
deleted_at timestamp with time zone,
|
||||||
|
metadata jsonb
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE customer_groups
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
name character varying NOT NULL,
|
||||||
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
deleted_at timestamp with time zone,
|
||||||
|
metadata jsonb
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE customer_group_customers
|
||||||
|
(
|
||||||
|
customer_group_id uuid NOT NULL,
|
||||||
|
customer_id uuid NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
------------------------------------------
|
||||||
|
------------------------------------------
|
||||||
|
------------------------------------------
|
||||||
|
|
||||||
|
CREATE TYPE user_roles AS ENUM (
|
||||||
|
'admin',
|
||||||
|
'member',
|
||||||
|
'developer'
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE users
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
email character varying NOT NULL,
|
||||||
|
first_name character varying,
|
||||||
|
last_name character varying,
|
||||||
|
password_hash character varying,
|
||||||
|
api_token character varying,
|
||||||
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
deleted_at timestamp with time zone,
|
||||||
|
metadata jsonb,
|
||||||
|
role user_roles DEFAULT 'member'::user_roles
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE addresses
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
customer_id uuid,
|
||||||
|
company character varying,
|
||||||
|
first_name character varying,
|
||||||
|
last_name character varying,
|
||||||
|
address_1 character varying,
|
||||||
|
address_2 character varying,
|
||||||
|
city character varying,
|
||||||
|
country_code character varying,
|
||||||
|
province character varying,
|
||||||
|
postal_code character varying,
|
||||||
|
phone character varying,
|
||||||
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
deleted_at timestamp with time zone,
|
||||||
|
metadata jsonb
|
||||||
|
);
|
@ -1,7 +1,3 @@
|
|||||||
--- DONE
|
|
||||||
--- DONE
|
|
||||||
--- DONE
|
|
||||||
|
|
||||||
CREATE TABLE tracking_links
|
CREATE TABLE tracking_links
|
||||||
(
|
(
|
||||||
id uuid NOT NULL,
|
id uuid NOT NULL,
|
||||||
@ -103,3 +99,66 @@ CREATE TABLE shipping_tax_rates
|
|||||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
metadata jsonb
|
metadata jsonb
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-----------------------------------------
|
||||||
|
-----------------------------------------
|
||||||
|
-----------------------------------------
|
||||||
|
-----------------------------------------
|
||||||
|
|
||||||
|
CREATE TABLE refunds
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
order_id uuid,
|
||||||
|
amount integer NOT NULL,
|
||||||
|
note character varying,
|
||||||
|
reason refund_reasons NOT NULL,
|
||||||
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
metadata jsonb,
|
||||||
|
idempotency_key character varying,
|
||||||
|
payment_id uuid
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE returns
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
status return_statuses DEFAULT 'requested'::return_statuses NOT NULL,
|
||||||
|
swap_id uuid,
|
||||||
|
order_id uuid,
|
||||||
|
shipping_data jsonb,
|
||||||
|
refund_amount integer NOT NULL,
|
||||||
|
received_at timestamp with time zone,
|
||||||
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
metadata jsonb,
|
||||||
|
idempotency_key character varying,
|
||||||
|
claim_order_id uuid,
|
||||||
|
no_notification boolean,
|
||||||
|
location_id uuid
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE return_items
|
||||||
|
(
|
||||||
|
return_id uuid NOT NULL,
|
||||||
|
item_id uuid NOT NULL,
|
||||||
|
quantity integer NOT NULL,
|
||||||
|
is_requested boolean DEFAULT true NOT NULL,
|
||||||
|
requested_quantity integer,
|
||||||
|
received_quantity integer,
|
||||||
|
metadata jsonb,
|
||||||
|
reason_id uuid,
|
||||||
|
note character varying
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE return_reasons
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
value character varying NOT NULL,
|
||||||
|
label character varying NOT NULL,
|
||||||
|
description character varying,
|
||||||
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
deleted_at timestamp with time zone,
|
||||||
|
metadata jsonb,
|
||||||
|
parent_return_reason_id uuid
|
||||||
|
);
|
||||||
|
40
migrations/20230603073532_checkouts.sql
Normal file
40
migrations/20230603073532_checkouts.sql
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
CREATE TYPE cart_types AS ENUM (
|
||||||
|
'default',
|
||||||
|
'swap',
|
||||||
|
'draft_order',
|
||||||
|
'payment_link',
|
||||||
|
'claim'
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE carts
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
email character varying,
|
||||||
|
billing_address_id uuid,
|
||||||
|
shipping_address_id uuid,
|
||||||
|
region_id uuid NOT NULL,
|
||||||
|
customer_id uuid,
|
||||||
|
payment_id uuid,
|
||||||
|
type cart_types DEFAULT 'default'::cart_types NOT NULL,
|
||||||
|
completed_at timestamp with time zone,
|
||||||
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
deleted_at timestamp with time zone,
|
||||||
|
metadata jsonb,
|
||||||
|
idempotency_key character varying,
|
||||||
|
context jsonb,
|
||||||
|
payment_authorized_at timestamp with time zone,
|
||||||
|
sales_channel_id uuid
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE cart_discounts
|
||||||
|
(
|
||||||
|
cart_id uuid NOT NULL,
|
||||||
|
discount_id uuid NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE cart_gift_cards
|
||||||
|
(
|
||||||
|
cart_id uuid NOT NULL,
|
||||||
|
gift_card_id uuid NOT NULL
|
||||||
|
);
|
150
migrations/20230603073532_marketing.sql
Normal file
150
migrations/20230603073532_marketing.sql
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
CREATE TABLE discounts
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
code character varying NOT NULL,
|
||||||
|
is_dynamic boolean NOT NULL,
|
||||||
|
rule_id uuid,
|
||||||
|
is_disabled boolean NOT NULL,
|
||||||
|
parent_discount_id uuid,
|
||||||
|
starts_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||||
|
ends_at timestamp with time zone,
|
||||||
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
deleted_at timestamp with time zone,
|
||||||
|
metadata jsonb,
|
||||||
|
usage_limit integer,
|
||||||
|
usage_count integer DEFAULT 0 NOT NULL,
|
||||||
|
valid_duration character varying
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE discount_conditions
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
type discount_condition_types NOT NULL,
|
||||||
|
operator discount_condition_operators NOT NULL,
|
||||||
|
discount_rule_id uuid NOT NULL,
|
||||||
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
deleted_at timestamp with time zone,
|
||||||
|
metadata jsonb
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE discount_condition_customer_groups
|
||||||
|
(
|
||||||
|
customer_group_id uuid NOT NULL,
|
||||||
|
condition_id uuid NOT NULL,
|
||||||
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
metadata jsonb
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE discount_condition_products
|
||||||
|
(
|
||||||
|
product_id uuid NOT NULL,
|
||||||
|
condition_id uuid NOT NULL,
|
||||||
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
metadata jsonb
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE discount_condition_product_collections
|
||||||
|
(
|
||||||
|
product_collection_id uuid NOT NULL,
|
||||||
|
condition_id uuid NOT NULL,
|
||||||
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
metadata jsonb
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE discount_condition_product_tags
|
||||||
|
(
|
||||||
|
product_tag_id uuid NOT NULL,
|
||||||
|
condition_id uuid NOT NULL,
|
||||||
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
metadata jsonb
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE discount_condition_product_types
|
||||||
|
(
|
||||||
|
product_type_id uuid NOT NULL,
|
||||||
|
condition_id uuid NOT NULL,
|
||||||
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
metadata jsonb
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE discount_regions
|
||||||
|
(
|
||||||
|
discount_id uuid NOT NULL,
|
||||||
|
region_id uuid NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE discount_rules
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
description character varying,
|
||||||
|
type discount_rule_types NOT NULL,
|
||||||
|
value integer NOT NULL,
|
||||||
|
allocation discount_rule_allocations,
|
||||||
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
deleted_at timestamp with time zone,
|
||||||
|
metadata jsonb
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE discount_rule_products
|
||||||
|
(
|
||||||
|
discount_rule_id uuid NOT NULL,
|
||||||
|
product_id uuid NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE gift_cards
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
code character varying NOT NULL,
|
||||||
|
value integer NOT NULL,
|
||||||
|
balance integer NOT NULL,
|
||||||
|
region_id uuid NOT NULL,
|
||||||
|
order_id uuid,
|
||||||
|
is_disabled boolean DEFAULT false NOT NULL,
|
||||||
|
ends_at timestamp with time zone,
|
||||||
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
deleted_at timestamp with time zone,
|
||||||
|
metadata jsonb,
|
||||||
|
tax_rate real
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE gift_card_transactions
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
gift_card_id uuid NOT NULL,
|
||||||
|
order_id uuid NOT NULL,
|
||||||
|
amount integer NOT NULL,
|
||||||
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
is_taxable boolean,
|
||||||
|
tax_rate real
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE sales_channels
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
deleted_at timestamp with time zone,
|
||||||
|
name character varying NOT NULL,
|
||||||
|
description character varying,
|
||||||
|
is_disabled boolean DEFAULT false NOT NULL,
|
||||||
|
metadata jsonb
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE sales_channel_locations
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
sales_channel_id text NOT NULL,
|
||||||
|
location_id text NOT NULL,
|
||||||
|
deleted_at timestamp with time zone
|
||||||
|
);
|
26
migrations/20230603073534_open_api.sql
Normal file
26
migrations/20230603073534_open_api.sql
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
CREATE TABLE oauth
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
display_name character varying NOT NULL,
|
||||||
|
application_name character varying NOT NULL,
|
||||||
|
install_url character varying,
|
||||||
|
uninstall_url character varying,
|
||||||
|
data jsonb
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE publishable_api_keys
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
created_by character varying,
|
||||||
|
revoked_by character varying,
|
||||||
|
revoked_at timestamp with time zone,
|
||||||
|
title character varying NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE publishable_api_key_sales_channels
|
||||||
|
(
|
||||||
|
sales_channel_id uuid NOT NULL,
|
||||||
|
publishable_key_id uuid NOT NULL
|
||||||
|
);
|
85
migrations/20230603073535_stores.sql
Normal file
85
migrations/20230603073535_stores.sql
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
CREATE TABLE stores
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
name character varying DEFAULT 'Bazaar'::character varying NOT NULL,
|
||||||
|
default_currency_code character varying DEFAULT 'pln'::character varying NOT NULL,
|
||||||
|
swap_link_template character varying,
|
||||||
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
metadata jsonb,
|
||||||
|
payment_link_template character varying,
|
||||||
|
invite_link_template character varying,
|
||||||
|
default_sales_channel_id uuid,
|
||||||
|
default_location_id uuid
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE store_currencies
|
||||||
|
(
|
||||||
|
store_id uuid NOT NULL,
|
||||||
|
currency_code character varying NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE tax_providers
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
is_installed boolean DEFAULT true NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE tax_rates
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
rate real,
|
||||||
|
code character varying,
|
||||||
|
name character varying NOT NULL,
|
||||||
|
region_id uuid NOT NULL,
|
||||||
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
metadata jsonb
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE region_fulfillment_providers
|
||||||
|
(
|
||||||
|
region_id uuid NOT NULL,
|
||||||
|
provider_id uuid NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE region_payment_providers
|
||||||
|
(
|
||||||
|
region_id uuid NOT NULL,
|
||||||
|
provider_id uuid NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE regions
|
||||||
|
(
|
||||||
|
id uuid NOT NULL,
|
||||||
|
name character varying NOT NULL,
|
||||||
|
currency_code character varying NOT NULL,
|
||||||
|
tax_rate real NOT NULL,
|
||||||
|
tax_code character varying,
|
||||||
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
deleted_at timestamp with time zone,
|
||||||
|
metadata jsonb,
|
||||||
|
gift_cards_taxable boolean DEFAULT true NOT NULL,
|
||||||
|
automatic_taxes boolean DEFAULT true NOT NULL,
|
||||||
|
tax_provider_id uuid
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE countries
|
||||||
|
(
|
||||||
|
id sequence NOT NULL,
|
||||||
|
iso_2 character varying NOT NULL,
|
||||||
|
iso_3 character varying NOT NULL,
|
||||||
|
num_code integer NOT NULL,
|
||||||
|
name character varying NOT NULL,
|
||||||
|
display_name character varying NOT NULL,
|
||||||
|
region_id uuid
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE currencies
|
||||||
|
(
|
||||||
|
code character varying NOT NULL,
|
||||||
|
symbol character varying NOT NULL,
|
||||||
|
symbol_native character varying NOT NULL,
|
||||||
|
name character varying NOT NULL
|
||||||
|
);
|
Loading…
Reference in New Issue
Block a user