#!/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