all
This commit is contained in:
1 parent
90125aede9
commit
2d6c29a1f3
404 files changed
+126983
-85
No files matched your search
@@ -0,0 +1,363 @@
|
||||
#!/usr/bin/env -S node
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const contract_json_1 = __importDefault(require("../../snapshots/a6d994c8ca49497bbabf294eb5fe9e8feb2cdafb62dfaf7c9a5b2c2e9135a15f/contract.json"));
|
||||
const migration_1 = require("@prisma/orm-postgres/migration");
|
||||
class M extends migration_1.Migration {
|
||||
endContractJson = contract_json_1.default;
|
||||
get operations() {
|
||||
return [
|
||||
this.createSchema({ schema: 'public' }),
|
||||
this.createTable({
|
||||
schema: 'public',
|
||||
table: 'cart_products',
|
||||
columns: [
|
||||
(0, migration_1.col)('cartId', 'int4', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
(0, migration_1.col)('historyId', 'int4', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
(0, migration_1.col)('quantity', 'int4', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
],
|
||||
constraints: [(0, migration_1.primaryKey)(['cartId', 'historyId'])],
|
||||
}),
|
||||
this.createTable({
|
||||
schema: 'public',
|
||||
table: 'category',
|
||||
columns: [
|
||||
(0, migration_1.col)('createdAt', 'timestamptz', {
|
||||
notNull: true,
|
||||
default: (0, migration_1.fn)('now()'),
|
||||
codecRef: { codecId: 'pg/timestamptz-string@1' },
|
||||
}),
|
||||
(0, migration_1.col)('id', 'SERIAL', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
(0, migration_1.col)('name', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }),
|
||||
],
|
||||
constraints: [(0, migration_1.primaryKey)(['id'])],
|
||||
}),
|
||||
this.createTable({
|
||||
schema: 'public',
|
||||
table: 'inventory',
|
||||
columns: [
|
||||
(0, migration_1.col)('id', 'SERIAL', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
(0, migration_1.col)('name', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }),
|
||||
],
|
||||
constraints: [(0, migration_1.primaryKey)(['id'])],
|
||||
}),
|
||||
this.createTable({
|
||||
schema: 'public',
|
||||
table: 'payment',
|
||||
columns: [
|
||||
(0, migration_1.col)('cartId', 'int4', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
(0, migration_1.col)('createdAt', 'timestamptz', {
|
||||
notNull: true,
|
||||
default: (0, migration_1.fn)('now()'),
|
||||
codecRef: { codecId: 'pg/timestamptz-string@1' },
|
||||
}),
|
||||
(0, migration_1.col)('id', 'SERIAL', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
(0, migration_1.col)('orderId', 'int4', { codecRef: { codecId: 'pg/int4@1' } }),
|
||||
(0, migration_1.col)('paid', 'bool', {
|
||||
notNull: true,
|
||||
default: (0, migration_1.lit)(false),
|
||||
codecRef: { codecId: 'pg/bool@1' },
|
||||
}),
|
||||
(0, migration_1.col)('paidAt', 'timestamptz', { codecRef: { codecId: 'pg/timestamptz-string@1' } }),
|
||||
(0, migration_1.col)('paymentMethod', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }),
|
||||
(0, migration_1.col)('status', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }),
|
||||
(0, migration_1.col)('terminalId', 'int4', { codecRef: { codecId: 'pg/int4@1' } }),
|
||||
(0, migration_1.col)('userId', 'int4', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
],
|
||||
constraints: [(0, migration_1.primaryKey)(['id'])],
|
||||
}),
|
||||
this.createTable({
|
||||
schema: 'public',
|
||||
table: 'product',
|
||||
columns: [
|
||||
(0, migration_1.col)('createdAt', 'timestamptz', {
|
||||
notNull: true,
|
||||
default: (0, migration_1.fn)('now()'),
|
||||
codecRef: { codecId: 'pg/timestamptz-string@1' },
|
||||
}),
|
||||
(0, migration_1.col)('description', 'text', { codecRef: { codecId: 'pg/text@1' } }),
|
||||
(0, migration_1.col)('id', 'SERIAL', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
(0, migration_1.col)('name', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }),
|
||||
(0, migration_1.col)('sku', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }),
|
||||
(0, migration_1.col)('supplierId', 'int4', { codecRef: { codecId: 'pg/int4@1' } }),
|
||||
],
|
||||
constraints: [(0, migration_1.primaryKey)(['id'])],
|
||||
}),
|
||||
this.createTable({
|
||||
schema: 'public',
|
||||
table: 'product_category',
|
||||
columns: [
|
||||
(0, migration_1.col)('categoryId', 'int4', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
(0, migration_1.col)('productId', 'int4', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
],
|
||||
constraints: [(0, migration_1.primaryKey)(['productId', 'categoryId'])],
|
||||
}),
|
||||
this.createTable({
|
||||
schema: 'public',
|
||||
table: 'product_history',
|
||||
columns: [
|
||||
(0, migration_1.col)('costUnit', 'numeric', { notNull: true, codecRef: { codecId: 'pg/numeric@1' } }),
|
||||
(0, migration_1.col)('createdAt', 'timestamptz', {
|
||||
notNull: true,
|
||||
default: (0, migration_1.fn)('now()'),
|
||||
codecRef: { codecId: 'pg/timestamptz-string@1' },
|
||||
}),
|
||||
(0, migration_1.col)('id', 'SERIAL', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
(0, migration_1.col)('productId', 'int4', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
(0, migration_1.col)('soldAt', 'timestamptz', { codecRef: { codecId: 'pg/timestamptz-string@1' } }),
|
||||
(0, migration_1.col)('status', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }),
|
||||
(0, migration_1.col)('unitPrice', 'numeric', { notNull: true, codecRef: { codecId: 'pg/numeric@1' } }),
|
||||
],
|
||||
constraints: [(0, migration_1.primaryKey)(['id'])],
|
||||
}),
|
||||
this.createTable({
|
||||
schema: 'public',
|
||||
table: 'shop_cart',
|
||||
columns: [
|
||||
(0, migration_1.col)('createdAt', 'timestamptz', {
|
||||
notNull: true,
|
||||
default: (0, migration_1.fn)('now()'),
|
||||
codecRef: { codecId: 'pg/timestamptz-string@1' },
|
||||
}),
|
||||
(0, migration_1.col)('id', 'SERIAL', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
(0, migration_1.col)('totalPrice', 'numeric', { notNull: true, codecRef: { codecId: 'pg/numeric@1' } }),
|
||||
(0, migration_1.col)('userId', 'int4', { codecRef: { codecId: 'pg/int4@1' } }),
|
||||
],
|
||||
constraints: [(0, migration_1.primaryKey)(['id'])],
|
||||
}),
|
||||
this.createTable({
|
||||
schema: 'public',
|
||||
table: 'supplier',
|
||||
columns: [
|
||||
(0, migration_1.col)('createdAt', 'timestamptz', {
|
||||
notNull: true,
|
||||
default: (0, migration_1.fn)('now()'),
|
||||
codecRef: { codecId: 'pg/timestamptz-string@1' },
|
||||
}),
|
||||
(0, migration_1.col)('id', 'SERIAL', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
(0, migration_1.col)('lastSupply', 'timestamptz', { codecRef: { codecId: 'pg/timestamptz-string@1' } }),
|
||||
(0, migration_1.col)('name', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }),
|
||||
],
|
||||
constraints: [(0, migration_1.primaryKey)(['id'])],
|
||||
}),
|
||||
this.createTable({
|
||||
schema: 'public',
|
||||
table: 'user',
|
||||
columns: [
|
||||
(0, migration_1.col)('createdAt', 'timestamptz', {
|
||||
notNull: true,
|
||||
default: (0, migration_1.fn)('now()'),
|
||||
codecRef: { codecId: 'pg/timestamptz-string@1' },
|
||||
}),
|
||||
(0, migration_1.col)('email', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }),
|
||||
(0, migration_1.col)('id', 'SERIAL', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
(0, migration_1.col)('name', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }),
|
||||
(0, migration_1.col)('password', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }),
|
||||
(0, migration_1.col)('role', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }),
|
||||
(0, migration_1.col)('updatedAt', 'timestamptz', {
|
||||
notNull: true,
|
||||
codecRef: { codecId: 'pg/timestamptz-string@1' },
|
||||
}),
|
||||
],
|
||||
constraints: [(0, migration_1.primaryKey)(['id'])],
|
||||
}),
|
||||
this.createTable({
|
||||
schema: 'public',
|
||||
table: 'warehouse',
|
||||
columns: [
|
||||
(0, migration_1.col)('inventoryId', 'int4', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
(0, migration_1.col)('productId', 'int4', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
(0, migration_1.col)('stock', 'int4', {
|
||||
notNull: true,
|
||||
default: (0, migration_1.lit)(0),
|
||||
codecRef: { codecId: 'pg/int4@1' },
|
||||
}),
|
||||
],
|
||||
constraints: [(0, migration_1.primaryKey)(['inventoryId', 'productId'])],
|
||||
}),
|
||||
this.addUnique({
|
||||
schema: 'public',
|
||||
table: 'product',
|
||||
constraint: 'product_sku_key',
|
||||
columns: ['sku'],
|
||||
}),
|
||||
this.addUnique({
|
||||
schema: 'public',
|
||||
table: 'user',
|
||||
constraint: 'user_email_key',
|
||||
columns: ['email'],
|
||||
}),
|
||||
this.createIndex({
|
||||
schema: 'public',
|
||||
table: 'cart_products',
|
||||
index: 'cart_products_cartId_idx_79939295',
|
||||
columns: ['cartId'],
|
||||
}),
|
||||
this.createIndex({
|
||||
schema: 'public',
|
||||
table: 'cart_products',
|
||||
index: 'cart_products_historyId_idx_dfaba3ef',
|
||||
columns: ['historyId'],
|
||||
}),
|
||||
this.createIndex({
|
||||
schema: 'public',
|
||||
table: 'payment',
|
||||
index: 'payment_cartId_idx_79939295',
|
||||
columns: ['cartId'],
|
||||
}),
|
||||
this.createIndex({
|
||||
schema: 'public',
|
||||
table: 'payment',
|
||||
index: 'payment_userId_idx_a489d58a',
|
||||
columns: ['userId'],
|
||||
}),
|
||||
this.createIndex({
|
||||
schema: 'public',
|
||||
table: 'product',
|
||||
index: 'product_supplierId_idx_c4d9a8b9',
|
||||
columns: ['supplierId'],
|
||||
}),
|
||||
this.createIndex({
|
||||
schema: 'public',
|
||||
table: 'product_category',
|
||||
index: 'product_category_categoryId_idx_15c304f2',
|
||||
columns: ['categoryId'],
|
||||
}),
|
||||
this.createIndex({
|
||||
schema: 'public',
|
||||
table: 'product_category',
|
||||
index: 'product_category_productId_idx_5858600a',
|
||||
columns: ['productId'],
|
||||
}),
|
||||
this.createIndex({
|
||||
schema: 'public',
|
||||
table: 'product_history',
|
||||
index: 'product_history_productId_idx_5858600a',
|
||||
columns: ['productId'],
|
||||
}),
|
||||
this.createIndex({
|
||||
schema: 'public',
|
||||
table: 'shop_cart',
|
||||
index: 'shop_cart_userId_idx_a489d58a',
|
||||
columns: ['userId'],
|
||||
}),
|
||||
this.createIndex({
|
||||
schema: 'public',
|
||||
table: 'warehouse',
|
||||
index: 'warehouse_inventoryId_idx_367f33d0',
|
||||
columns: ['inventoryId'],
|
||||
}),
|
||||
this.createIndex({
|
||||
schema: 'public',
|
||||
table: 'warehouse',
|
||||
index: 'warehouse_productId_idx_5858600a',
|
||||
columns: ['productId'],
|
||||
}),
|
||||
this.addForeignKey({
|
||||
schema: 'public',
|
||||
table: 'cart_products',
|
||||
foreignKey: {
|
||||
name: 'cart_products_cartId_fkey',
|
||||
columns: ['cartId'],
|
||||
references: { schema: 'public', table: 'shop_cart', columns: ['id'] },
|
||||
},
|
||||
}),
|
||||
this.addForeignKey({
|
||||
schema: 'public',
|
||||
table: 'cart_products',
|
||||
foreignKey: {
|
||||
name: 'cart_products_historyId_fkey',
|
||||
columns: ['historyId'],
|
||||
references: { schema: 'public', table: 'product_history', columns: ['id'] },
|
||||
},
|
||||
}),
|
||||
this.addForeignKey({
|
||||
schema: 'public',
|
||||
table: 'payment',
|
||||
foreignKey: {
|
||||
name: 'payment_cartId_fkey',
|
||||
columns: ['cartId'],
|
||||
references: { schema: 'public', table: 'shop_cart', columns: ['id'] },
|
||||
},
|
||||
}),
|
||||
this.addForeignKey({
|
||||
schema: 'public',
|
||||
table: 'payment',
|
||||
foreignKey: {
|
||||
name: 'payment_userId_fkey',
|
||||
columns: ['userId'],
|
||||
references: { schema: 'public', table: 'user', columns: ['id'] },
|
||||
},
|
||||
}),
|
||||
this.addForeignKey({
|
||||
schema: 'public',
|
||||
table: 'product',
|
||||
foreignKey: {
|
||||
name: 'product_supplierId_fkey',
|
||||
columns: ['supplierId'],
|
||||
references: { schema: 'public', table: 'supplier', columns: ['id'] },
|
||||
},
|
||||
}),
|
||||
this.addForeignKey({
|
||||
schema: 'public',
|
||||
table: 'product_category',
|
||||
foreignKey: {
|
||||
name: 'product_category_productId_fkey',
|
||||
columns: ['productId'],
|
||||
references: { schema: 'public', table: 'product', columns: ['id'] },
|
||||
},
|
||||
}),
|
||||
this.addForeignKey({
|
||||
schema: 'public',
|
||||
table: 'product_category',
|
||||
foreignKey: {
|
||||
name: 'product_category_categoryId_fkey',
|
||||
columns: ['categoryId'],
|
||||
references: { schema: 'public', table: 'category', columns: ['id'] },
|
||||
},
|
||||
}),
|
||||
this.addForeignKey({
|
||||
schema: 'public',
|
||||
table: 'product_history',
|
||||
foreignKey: {
|
||||
name: 'product_history_productId_fkey',
|
||||
columns: ['productId'],
|
||||
references: { schema: 'public', table: 'product', columns: ['id'] },
|
||||
},
|
||||
}),
|
||||
this.addForeignKey({
|
||||
schema: 'public',
|
||||
table: 'shop_cart',
|
||||
foreignKey: {
|
||||
name: 'shop_cart_userId_fkey',
|
||||
columns: ['userId'],
|
||||
references: { schema: 'public', table: 'user', columns: ['id'] },
|
||||
},
|
||||
}),
|
||||
this.addForeignKey({
|
||||
schema: 'public',
|
||||
table: 'warehouse',
|
||||
foreignKey: {
|
||||
name: 'warehouse_inventoryId_fkey',
|
||||
columns: ['inventoryId'],
|
||||
references: { schema: 'public', table: 'inventory', columns: ['id'] },
|
||||
},
|
||||
}),
|
||||
this.addForeignKey({
|
||||
schema: 'public',
|
||||
table: 'warehouse',
|
||||
foreignKey: {
|
||||
name: 'warehouse_productId_fkey',
|
||||
columns: ['productId'],
|
||||
references: { schema: 'public', table: 'product', columns: ['id'] },
|
||||
},
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
exports.default = M;
|
||||
migration_1.MigrationCLI.run(import.meta.url, M);
|
||||
//# sourceMappingURL=migration.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"migration.js","sourceRoot":"","sources":["migration.ts"],"names":[],"mappings":";;;;;;AAEA,mJAA+I;AAC/I,8DAAmG;AAEnG,MAAqB,CAAE,SAAQ,qBAAqB;IAChC,eAAe,GAAG,uBAAW,CAAC;IAEhD,IAAa,UAAU;QACrB,OAAO;YACL,IAAI,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;YACvC,IAAI,CAAC,WAAW,CAAC;gBACf,MAAM,EAAE,QAAQ;gBAChB,KAAK,EAAE,eAAe;gBACtB,OAAO,EAAE;oBACP,IAAA,eAAG,EAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,CAAC;oBAC5E,IAAA,eAAG,EAAC,WAAW,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,CAAC;oBAC/E,IAAA,eAAG,EAAC,UAAU,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,CAAC;iBAC/E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,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,CAAC;oBAC/E,IAAA,eAAG,EAAC,QAAQ,EAAE,aAAa,EAAE,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,yBAAyB,EAAE,EAAE,CAAC;oBAClF,IAAA,eAAG,EAAC,QAAQ,EAAE,MAAM,EAAE,Line truncated
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"from": null,
|
||||
"to": "a6d994c8ca49497bbabf294eb5fe9e8feb2cdafb62dfaf7c9a5b2c2e9135a15f",
|
||||
"providedInvariants": [],
|
||||
"createdAt": "2026-09-28T19:10:54.766Z",
|
||||
"migrationHash": "e54c1d31bafdfcf8fbbf8ac2f901f904562be301481a310ae7e89b870eb58457"
|
||||
}
|
||||
+360
@@ -0,0 +1,360 @@
|
||||
#!/usr/bin/env -S node
|
||||
import type { Contract as End } from '../../snapshots/a6d994c8ca49497bbabf294eb5fe9e8feb2cdafb62dfaf7c9a5b2c2e9135a15f/contract';
|
||||
import endContract from '../../snapshots/a6d994c8ca49497bbabf294eb5fe9e8feb2cdafb62dfaf7c9a5b2c2e9135a15f/contract.json' with { type: 'json' };
|
||||
import { Migration, MigrationCLI, col, fn, lit, primaryKey } from '@prisma/orm-postgres/migration';
|
||||
|
||||
export default class M extends Migration<never, End> {
|
||||
override readonly endContractJson = endContract;
|
||||
|
||||
override get operations() {
|
||||
return [
|
||||
this.createSchema({ schema: 'public' }),
|
||||
this.createTable({
|
||||
schema: 'public',
|
||||
table: 'cart_products',
|
||||
columns: [
|
||||
col('cartId', 'int4', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
col('historyId', 'int4', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
col('quantity', 'int4', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
],
|
||||
constraints: [primaryKey(['cartId', 'historyId'])],
|
||||
}),
|
||||
this.createTable({
|
||||
schema: 'public',
|
||||
table: 'category',
|
||||
columns: [
|
||||
col('createdAt', 'timestamptz', {
|
||||
notNull: true,
|
||||
default: fn('now()'),
|
||||
codecRef: { codecId: 'pg/timestamptz-string@1' },
|
||||
}),
|
||||
col('id', 'SERIAL', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
col('name', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }),
|
||||
],
|
||||
constraints: [primaryKey(['id'])],
|
||||
}),
|
||||
this.createTable({
|
||||
schema: 'public',
|
||||
table: 'inventory',
|
||||
columns: [
|
||||
col('id', 'SERIAL', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
col('name', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }),
|
||||
],
|
||||
constraints: [primaryKey(['id'])],
|
||||
}),
|
||||
this.createTable({
|
||||
schema: 'public',
|
||||
table: 'payment',
|
||||
columns: [
|
||||
col('cartId', 'int4', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
col('createdAt', 'timestamptz', {
|
||||
notNull: true,
|
||||
default: fn('now()'),
|
||||
codecRef: { codecId: 'pg/timestamptz-string@1' },
|
||||
}),
|
||||
col('id', 'SERIAL', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
col('orderId', 'int4', { codecRef: { codecId: 'pg/int4@1' } }),
|
||||
col('paid', 'bool', {
|
||||
notNull: true,
|
||||
default: lit(false),
|
||||
codecRef: { codecId: 'pg/bool@1' },
|
||||
}),
|
||||
col('paidAt', 'timestamptz', { codecRef: { codecId: 'pg/timestamptz-string@1' } }),
|
||||
col('paymentMethod', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }),
|
||||
col('status', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }),
|
||||
col('terminalId', 'int4', { codecRef: { codecId: 'pg/int4@1' } }),
|
||||
col('userId', 'int4', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
],
|
||||
constraints: [primaryKey(['id'])],
|
||||
}),
|
||||
this.createTable({
|
||||
schema: 'public',
|
||||
table: 'product',
|
||||
columns: [
|
||||
col('createdAt', 'timestamptz', {
|
||||
notNull: true,
|
||||
default: fn('now()'),
|
||||
codecRef: { codecId: 'pg/timestamptz-string@1' },
|
||||
}),
|
||||
col('description', 'text', { codecRef: { codecId: 'pg/text@1' } }),
|
||||
col('id', 'SERIAL', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
col('name', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }),
|
||||
col('sku', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }),
|
||||
col('supplierId', 'int4', { codecRef: { codecId: 'pg/int4@1' } }),
|
||||
],
|
||||
constraints: [primaryKey(['id'])],
|
||||
}),
|
||||
this.createTable({
|
||||
schema: 'public',
|
||||
table: 'product_category',
|
||||
columns: [
|
||||
col('categoryId', 'int4', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
col('productId', 'int4', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
],
|
||||
constraints: [primaryKey(['productId', 'categoryId'])],
|
||||
}),
|
||||
this.createTable({
|
||||
schema: 'public',
|
||||
table: 'product_history',
|
||||
columns: [
|
||||
col('costUnit', 'numeric', { notNull: true, codecRef: { codecId: 'pg/numeric@1' } }),
|
||||
col('createdAt', 'timestamptz', {
|
||||
notNull: true,
|
||||
default: fn('now()'),
|
||||
codecRef: { codecId: 'pg/timestamptz-string@1' },
|
||||
}),
|
||||
col('id', 'SERIAL', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
col('productId', 'int4', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
col('soldAt', 'timestamptz', { codecRef: { codecId: 'pg/timestamptz-string@1' } }),
|
||||
col('status', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }),
|
||||
col('unitPrice', 'numeric', { notNull: true, codecRef: { codecId: 'pg/numeric@1' } }),
|
||||
],
|
||||
constraints: [primaryKey(['id'])],
|
||||
}),
|
||||
this.createTable({
|
||||
schema: 'public',
|
||||
table: 'shop_cart',
|
||||
columns: [
|
||||
col('createdAt', 'timestamptz', {
|
||||
notNull: true,
|
||||
default: fn('now()'),
|
||||
codecRef: { codecId: 'pg/timestamptz-string@1' },
|
||||
}),
|
||||
col('id', 'SERIAL', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
col('totalPrice', 'numeric', { notNull: true, codecRef: { codecId: 'pg/numeric@1' } }),
|
||||
col('userId', 'int4', { codecRef: { codecId: 'pg/int4@1' } }),
|
||||
],
|
||||
constraints: [primaryKey(['id'])],
|
||||
}),
|
||||
this.createTable({
|
||||
schema: 'public',
|
||||
table: 'supplier',
|
||||
columns: [
|
||||
col('createdAt', 'timestamptz', {
|
||||
notNull: true,
|
||||
default: fn('now()'),
|
||||
codecRef: { codecId: 'pg/timestamptz-string@1' },
|
||||
}),
|
||||
col('id', 'SERIAL', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
col('lastSupply', 'timestamptz', { codecRef: { codecId: 'pg/timestamptz-string@1' } }),
|
||||
col('name', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }),
|
||||
],
|
||||
constraints: [primaryKey(['id'])],
|
||||
}),
|
||||
this.createTable({
|
||||
schema: 'public',
|
||||
table: 'user',
|
||||
columns: [
|
||||
col('createdAt', 'timestamptz', {
|
||||
notNull: true,
|
||||
default: fn('now()'),
|
||||
codecRef: { codecId: 'pg/timestamptz-string@1' },
|
||||
}),
|
||||
col('email', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }),
|
||||
col('id', 'SERIAL', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
col('name', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }),
|
||||
col('password', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }),
|
||||
col('role', 'text', { notNull: true, codecRef: { codecId: 'pg/text@1' } }),
|
||||
col('updatedAt', 'timestamptz', {
|
||||
notNull: true,
|
||||
codecRef: { codecId: 'pg/timestamptz-string@1' },
|
||||
}),
|
||||
],
|
||||
constraints: [primaryKey(['id'])],
|
||||
}),
|
||||
this.createTable({
|
||||
schema: 'public',
|
||||
table: 'warehouse',
|
||||
columns: [
|
||||
col('inventoryId', 'int4', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
col('productId', 'int4', { notNull: true, codecRef: { codecId: 'pg/int4@1' } }),
|
||||
col('stock', 'int4', {
|
||||
notNull: true,
|
||||
default: lit(0),
|
||||
codecRef: { codecId: 'pg/int4@1' },
|
||||
}),
|
||||
],
|
||||
constraints: [primaryKey(['inventoryId', 'productId'])],
|
||||
}),
|
||||
this.addUnique({
|
||||
schema: 'public',
|
||||
table: 'product',
|
||||
constraint: 'product_sku_key',
|
||||
columns: ['sku'],
|
||||
}),
|
||||
this.addUnique({
|
||||
schema: 'public',
|
||||
table: 'user',
|
||||
constraint: 'user_email_key',
|
||||
columns: ['email'],
|
||||
}),
|
||||
this.createIndex({
|
||||
schema: 'public',
|
||||
table: 'cart_products',
|
||||
index: 'cart_products_cartId_idx_79939295',
|
||||
columns: ['cartId'],
|
||||
}),
|
||||
this.createIndex({
|
||||
schema: 'public',
|
||||
table: 'cart_products',
|
||||
index: 'cart_products_historyId_idx_dfaba3ef',
|
||||
columns: ['historyId'],
|
||||
}),
|
||||
this.createIndex({
|
||||
schema: 'public',
|
||||
table: 'payment',
|
||||
index: 'payment_cartId_idx_79939295',
|
||||
columns: ['cartId'],
|
||||
}),
|
||||
this.createIndex({
|
||||
schema: 'public',
|
||||
table: 'payment',
|
||||
index: 'payment_userId_idx_a489d58a',
|
||||
columns: ['userId'],
|
||||
}),
|
||||
this.createIndex({
|
||||
schema: 'public',
|
||||
table: 'product',
|
||||
index: 'product_supplierId_idx_c4d9a8b9',
|
||||
columns: ['supplierId'],
|
||||
}),
|
||||
this.createIndex({
|
||||
schema: 'public',
|
||||
table: 'product_category',
|
||||
index: 'product_category_categoryId_idx_15c304f2',
|
||||
columns: ['categoryId'],
|
||||
}),
|
||||
this.createIndex({
|
||||
schema: 'public',
|
||||
table: 'product_category',
|
||||
index: 'product_category_productId_idx_5858600a',
|
||||
columns: ['productId'],
|
||||
}),
|
||||
this.createIndex({
|
||||
schema: 'public',
|
||||
table: 'product_history',
|
||||
index: 'product_history_productId_idx_5858600a',
|
||||
columns: ['productId'],
|
||||
}),
|
||||
this.createIndex({
|
||||
schema: 'public',
|
||||
table: 'shop_cart',
|
||||
index: 'shop_cart_userId_idx_a489d58a',
|
||||
columns: ['userId'],
|
||||
}),
|
||||
this.createIndex({
|
||||
schema: 'public',
|
||||
table: 'warehouse',
|
||||
index: 'warehouse_inventoryId_idx_367f33d0',
|
||||
columns: ['inventoryId'],
|
||||
}),
|
||||
this.createIndex({
|
||||
schema: 'public',
|
||||
table: 'warehouse',
|
||||
index: 'warehouse_productId_idx_5858600a',
|
||||
columns: ['productId'],
|
||||
}),
|
||||
this.addForeignKey({
|
||||
schema: 'public',
|
||||
table: 'cart_products',
|
||||
foreignKey: {
|
||||
name: 'cart_products_cartId_fkey',
|
||||
columns: ['cartId'],
|
||||
references: { schema: 'public', table: 'shop_cart', columns: ['id'] },
|
||||
},
|
||||
}),
|
||||
this.addForeignKey({
|
||||
schema: 'public',
|
||||
table: 'cart_products',
|
||||
foreignKey: {
|
||||
name: 'cart_products_historyId_fkey',
|
||||
columns: ['historyId'],
|
||||
references: { schema: 'public', table: 'product_history', columns: ['id'] },
|
||||
},
|
||||
}),
|
||||
this.addForeignKey({
|
||||
schema: 'public',
|
||||
table: 'payment',
|
||||
foreignKey: {
|
||||
name: 'payment_cartId_fkey',
|
||||
columns: ['cartId'],
|
||||
references: { schema: 'public', table: 'shop_cart', columns: ['id'] },
|
||||
},
|
||||
}),
|
||||
this.addForeignKey({
|
||||
schema: 'public',
|
||||
table: 'payment',
|
||||
foreignKey: {
|
||||
name: 'payment_userId_fkey',
|
||||
columns: ['userId'],
|
||||
references: { schema: 'public', table: 'user', columns: ['id'] },
|
||||
},
|
||||
}),
|
||||
this.addForeignKey({
|
||||
schema: 'public',
|
||||
table: 'product',
|
||||
foreignKey: {
|
||||
name: 'product_supplierId_fkey',
|
||||
columns: ['supplierId'],
|
||||
references: { schema: 'public', table: 'supplier', columns: ['id'] },
|
||||
},
|
||||
}),
|
||||
this.addForeignKey({
|
||||
schema: 'public',
|
||||
table: 'product_category',
|
||||
foreignKey: {
|
||||
name: 'product_category_productId_fkey',
|
||||
columns: ['productId'],
|
||||
references: { schema: 'public', table: 'product', columns: ['id'] },
|
||||
},
|
||||
}),
|
||||
this.addForeignKey({
|
||||
schema: 'public',
|
||||
table: 'product_category',
|
||||
foreignKey: {
|
||||
name: 'product_category_categoryId_fkey',
|
||||
columns: ['categoryId'],
|
||||
references: { schema: 'public', table: 'category', columns: ['id'] },
|
||||
},
|
||||
}),
|
||||
this.addForeignKey({
|
||||
schema: 'public',
|
||||
table: 'product_history',
|
||||
foreignKey: {
|
||||
name: 'product_history_productId_fkey',
|
||||
columns: ['productId'],
|
||||
references: { schema: 'public', table: 'product', columns: ['id'] },
|
||||
},
|
||||
}),
|
||||
this.addForeignKey({
|
||||
schema: 'public',
|
||||
table: 'shop_cart',
|
||||
foreignKey: {
|
||||
name: 'shop_cart_userId_fkey',
|
||||
columns: ['userId'],
|
||||
references: { schema: 'public', table: 'user', columns: ['id'] },
|
||||
},
|
||||
}),
|
||||
this.addForeignKey({
|
||||
schema: 'public',
|
||||
table: 'warehouse',
|
||||
foreignKey: {
|
||||
name: 'warehouse_inventoryId_fkey',
|
||||
columns: ['inventoryId'],
|
||||
references: { schema: 'public', table: 'inventory', columns: ['id'] },
|
||||
},
|
||||
}),
|
||||
this.addForeignKey({
|
||||
schema: 'public',
|
||||
table: 'warehouse',
|
||||
foreignKey: {
|
||||
name: 'warehouse_productId_fkey',
|
||||
columns: ['productId'],
|
||||
references: { schema: 'public', table: 'product', columns: ['id'] },
|
||||
},
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
MigrationCLI.run(import.meta.url, M);
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"hash": "b5e61e3bbb48a37870fbaa4f995b31a2f79884401b2346370519c5b9bf61e6d9",
|
||||
"invariants": []
|
||||
}
|
||||
Reference in new issue
Block a user