feat: add stock keeping unit management with create, update, and retrieval functionalities
- Implemented CreateStockKeepingUnitDto for creating stock keeping units. - Added StockKeepingUnitsService for handling business logic related to stock keeping units. - Created StockKeepingUnitsController to manage HTTP requests for stock keeping units. - Developed UpdateStockKeepingUnitDto for updating existing stock keeping units. - Introduced StockKeepingUnitsServiceFindAllResponseDto for response structure. - Established stock keeping units module for encapsulation of related components. feat: enhance sales invoice fiscal management with new endpoints - Created SalesInvoicesFilterDto for filtering sales invoices. - Implemented PosSalesInvoiceFiscalController for managing fiscal operations on sales invoices. - Developed PosSalesInvoiceFiscalService to handle fiscal logic and interactions. - Added methods for sending, retrying, and checking the status of fiscal invoices. - Integrated error handling and response mapping for fiscal operations.
This commit is contained in:
@@ -1,50 +0,0 @@
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `permission_business_activities` DROP FOREIGN KEY `permission_business_activities_business_id_fkey`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `permission_business_activities` DROP FOREIGN KEY `permission_business_activities_permission_id_fkey`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `permission_complexes` DROP FOREIGN KEY `permission_complexes_complex_id_fkey`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `permission_complexes` DROP FOREIGN KEY `permission_complexes_permission_id_fkey`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `permission_consumers` DROP FOREIGN KEY `permission_consumers_consumer_account_id_fkey`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `permission_poses` DROP FOREIGN KEY `permission_poses_permission_id_fkey`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `permission_poses` DROP FOREIGN KEY `permission_poses_pos_id_fkey`;
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX `permission_business_activities_business_id_fkey` ON `permission_business_activities`;
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX `permission_complexes_complex_id_fkey` ON `permission_complexes`;
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX `permission_poses_pos_id_fkey` ON `permission_poses`;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `permission_consumers` ADD CONSTRAINT `permission_consumers_consumer_account_id_fkey` FOREIGN KEY (`consumer_account_id`) REFERENCES `consumer_accounts`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `permission_poses` ADD CONSTRAINT `permission_poses_pos_id_fkey` FOREIGN KEY (`pos_id`) REFERENCES `poses`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `permission_poses` ADD CONSTRAINT `permission_poses_permission_id_fkey` FOREIGN KEY (`permission_id`) REFERENCES `permission_consumers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `permission_complexes` ADD CONSTRAINT `permission_complexes_complex_id_fkey` FOREIGN KEY (`complex_id`) REFERENCES `complexes`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `permission_complexes` ADD CONSTRAINT `permission_complexes_permission_id_fkey` FOREIGN KEY (`permission_id`) REFERENCES `permission_consumers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `permission_business_activities` ADD CONSTRAINT `permission_business_activities_business_id_fkey` FOREIGN KEY (`business_id`) REFERENCES `business_activities`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `permission_business_activities` ADD CONSTRAINT `permission_business_activities_permission_id_fkey` FOREIGN KEY (`permission_id`) REFERENCES `permission_consumers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -1,2 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE `goods` ADD COLUMN `image_url` VARCHAR(255) NULL;
|
||||
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `consumer_id` on the `licenses` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `expires_at` on the `licenses` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `starts_at` on the `licenses` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `status` on the `licenses` table. All the data in the column will be lost.
|
||||
- A unique constraint covering the columns `[activated_license_id]` on the table `consumers` will be added. If there are existing duplicate values, this will fail.
|
||||
- Added the required column `activation_expires_at` to the `licenses` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `charged_license_transaction_id` to the `licenses` table without a default value. This is not possible if the table is not empty.
|
||||
- Made the column `partner_id` on table `licenses` required. This step will fail if there are existing NULL values in that column.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `licenses` DROP FOREIGN KEY `licenses_consumer_id_fkey`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `licenses` DROP FOREIGN KEY `licenses_partner_id_fkey`;
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX `licenses_consumer_id_key` ON `licenses`;
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX `licenses_partner_id_fkey` ON `licenses`;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `consumers` ADD COLUMN `activated_license_id` VARCHAR(191) NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `licenses` DROP COLUMN `consumer_id`,
|
||||
DROP COLUMN `expires_at`,
|
||||
DROP COLUMN `starts_at`,
|
||||
DROP COLUMN `status`,
|
||||
ADD COLUMN `activation_expires_at` DATETIME(3) NOT NULL,
|
||||
ADD COLUMN `charged_license_transaction_id` VARCHAR(191) NOT NULL,
|
||||
MODIFY `partner_id` VARCHAR(191) NOT NULL;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `activated_licenses` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`starts_at` DATETIME(3) NOT NULL,
|
||||
`expires_at` DATETIME(3) NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`license_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `activated_licenses_id_key`(`id`),
|
||||
UNIQUE INDEX `activated_licenses_license_id_key`(`license_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `charged_license_transactions` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`partner_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX `consumers_activated_license_id_key` ON `consumers`(`activated_license_id`);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `consumers` ADD CONSTRAINT `consumers_activated_license_id_fkey` FOREIGN KEY (`activated_license_id`) REFERENCES `activated_licenses`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `licenses` ADD CONSTRAINT `licenses_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `licenses` ADD CONSTRAINT `licenses_charged_license_transaction_id_fkey` FOREIGN KEY (`charged_license_transaction_id`) REFERENCES `charged_license_transactions`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `activated_licenses` ADD CONSTRAINT `activated_licenses_license_id_fkey` FOREIGN KEY (`license_id`) REFERENCES `licenses`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `charged_license_transactions` ADD CONSTRAINT `charged_license_transactions_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `activated_license_id` on the `consumers` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `activation_expires_at` on the `licenses` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `partner_id` on the `licenses` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `license_quota` on the `partners` table. All the data in the column will be lost.
|
||||
- Added the required column `consumer_id` to the `activated_licenses` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `activation_expires_at` to the `charged_license_transactions` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `consumers` DROP FOREIGN KEY `consumers_activated_license_id_fkey`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `licenses` DROP FOREIGN KEY `licenses_partner_id_fkey`;
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX `consumers_activated_license_id_key` ON `consumers`;
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX `licenses_partner_id_fkey` ON `licenses`;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `activated_licenses` ADD COLUMN `consumer_id` VARCHAR(191) NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `charged_license_transactions` ADD COLUMN `activation_expires_at` DATETIME(3) NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `consumers` DROP COLUMN `activated_license_id`;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `licenses` DROP COLUMN `activation_expires_at`,
|
||||
DROP COLUMN `partner_id`;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `partners` DROP COLUMN `license_quota`;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `activated_licenses` ADD CONSTRAINT `activated_licenses_consumer_id_fkey` FOREIGN KEY (`consumer_id`) REFERENCES `consumers`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
-70
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the `user_devices` table. If the table is not empty, all the data it contains will be lost.
|
||||
- A unique constraint covering the columns `[tracking_code]` on the table `charged_license_transactions` will be added. If there are existing duplicate values, this will fail.
|
||||
- Added the required column `tracking_code` to the `charged_license_transactions` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- DropTable
|
||||
DROP TABLE `user_devices`;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `consumer_devices` (
|
||||
`uuid` VARCHAR(255) NOT NULL,
|
||||
`app_version` VARCHAR(20) NOT NULL,
|
||||
`build_number` VARCHAR(20) NOT NULL,
|
||||
`platform` VARCHAR(100) NOT NULL,
|
||||
`brand` VARCHAR(100) NOT NULL,
|
||||
`model` VARCHAR(100) NOT NULL,
|
||||
`device` VARCHAR(100) NOT NULL,
|
||||
`os_version` VARCHAR(20) NOT NULL,
|
||||
`sdk_version` VARCHAR(20) NOT NULL,
|
||||
`release_number` VARCHAR(20) NOT NULL,
|
||||
`browser_name` VARCHAR(100) NULL,
|
||||
`fcm_token` VARCHAR(100) NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`consumer_id` VARCHAR(191) NOT NULL,
|
||||
UNIQUE INDEX `consumer_devices_uuid_key` (`uuid`),
|
||||
PRIMARY KEY (`uuid`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `application_released_info` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`version` VARCHAR(191) NOT NULL,
|
||||
`build_number` VARCHAR(191) NOT NULL,
|
||||
`is_stable` BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
`is_minimum_supported` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
`type` ENUM('ANDROID', 'IOS') NOT NULL,
|
||||
`notes` JSON NULL,
|
||||
`release_date` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `consumer_devices`
|
||||
ADD CONSTRAINT `consumer_devices_consumer_id_fkey` FOREIGN KEY (`consumer_id`) REFERENCES `consumers` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE `charged_license_transactions`
|
||||
ADD COLUMN `tracking_code` VARCHAR(191) NULL;
|
||||
|
||||
UPDATE `charged_license_transactions`
|
||||
SET
|
||||
`tracking_code` = CONCAT(
|
||||
'TRX-',
|
||||
UPPER(
|
||||
REPLACE (`id`, '-', '')
|
||||
)
|
||||
)
|
||||
WHERE
|
||||
`tracking_code` IS NULL
|
||||
OR `tracking_code` = '';
|
||||
|
||||
ALTER TABLE `charged_license_transactions`
|
||||
MODIFY `tracking_code` VARCHAR(191) NOT NULL;
|
||||
|
||||
CREATE UNIQUE INDEX `charged_license_transactions_tracking_code_key` ON `charged_license_transactions` (`tracking_code`);
|
||||
@@ -1,19 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `is_stable` on the `application_released_info` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `type` on the `application_released_info` table. All the data in the column will be lost.
|
||||
- Added the required column `platform` to the `application_released_info` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `release_type` to the `application_released_info` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `publisher` to the `consumer_devices` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE `application_released_info` DROP COLUMN `is_stable`,
|
||||
DROP COLUMN `type`,
|
||||
ADD COLUMN `platform` ENUM('ANDROID', 'IOS') NOT NULL,
|
||||
ADD COLUMN `release_type` ENUM('STABLE', 'BETA', 'ALPHA') NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `consumer_devices` ADD COLUMN `publisher` ENUM('DIRECT', 'CAFE_BAZAR', 'MAYKET') NOT NULL,
|
||||
ADD COLUMN `user_agent` VARCHAR(100) NULL;
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `tax_id` on the `complexes` table. All the data in the column will be lost.
|
||||
- A unique constraint covering the columns `[economic_code]` on the table `business_activities` will be added. If there are existing duplicate values, this will fail.
|
||||
- A unique constraint covering the columns `[mobile_number,national_code,partner_id]` on the table `consumers` will be added. If there are existing duplicate values, this will fail.
|
||||
- Added the required column `economic_code` to the `business_activities` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `national_code` to the `consumers` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `partner_id` to the `consumers` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- DropIndex
|
||||
DROP INDEX `consumers_mobile_number_key` ON `consumers`;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `business_activities` ADD COLUMN `economic_code` VARCHAR(191) NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `complexes` DROP COLUMN `tax_id`;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `consumers` ADD COLUMN `national_code` VARCHAR(191) NOT NULL,
|
||||
ADD COLUMN `partner_id` VARCHAR(191) NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `licenses` ADD COLUMN `accounts_limit` INTEGER NOT NULL DEFAULT 3;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX `business_activities_economic_code_key` ON `business_activities`(`economic_code`);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX `consumers_mobile_number_national_code_partner_id_key` ON `consumers`(`mobile_number`, `national_code`, `partner_id`);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `consumers` ADD CONSTRAINT `consumers_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- Added the required column `branch_code` to the `complexes` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE `complexes` ADD COLUMN `branch_code` VARCHAR(191) NOT NULL;
|
||||
@@ -1,151 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `charged_license_transaction_id` on the `licenses` table. All the data in the column will be lost.
|
||||
- You are about to drop the `activated_licenses` table. If the table is not empty, all the data it contains will be lost.
|
||||
- You are about to drop the `charged_license_transactions` table. If the table is not empty, all the data it contains will be lost.
|
||||
- A unique constraint covering the columns `[mobile_number,partner_id]` on the table `consumers` will be added. If there are existing duplicate values, this will fail.
|
||||
- A unique constraint covering the columns `[national_code,partner_id]` on the table `consumers` will be added. If there are existing duplicate values, this will fail.
|
||||
- Added the required column `charge_transaction_id` to the `licenses` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `activated_licenses` DROP FOREIGN KEY `activated_licenses_consumer_id_fkey`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `activated_licenses` DROP FOREIGN KEY `activated_licenses_license_id_fkey`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `charged_license_transactions` DROP FOREIGN KEY `charged_license_transactions_partner_id_fkey`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `licenses` DROP FOREIGN KEY `licenses_charged_license_transaction_id_fkey`;
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX `consumers_mobile_number_national_code_partner_id_key` ON `consumers`;
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX `licenses_charged_license_transaction_id_fkey` ON `licenses`;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `licenses` DROP COLUMN `charged_license_transaction_id`,
|
||||
ADD COLUMN `charge_transaction_id` VARCHAR(191) NOT NULL;
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE `activated_licenses`;
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE `charged_license_transactions`;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `licenses_activated` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`starts_at` DATETIME(3) NOT NULL,
|
||||
`expires_at` DATETIME(3) NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`license_id` VARCHAR(191) NOT NULL,
|
||||
`business_activity_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `licenses_activated_id_key`(`id`),
|
||||
UNIQUE INDEX `licenses_activated_license_id_key`(`license_id`),
|
||||
UNIQUE INDEX `licenses_activated_business_activity_id_key`(`business_activity_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `license_charged_transactions` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`activation_expires_at` DATETIME(3) NOT NULL,
|
||||
`tracking_code` VARCHAR(191) NOT NULL,
|
||||
`purchased_count` INTEGER NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`partner_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `license_charged_transactions_tracking_code_key`(`tracking_code`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `license_renew` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`charge_transaction_id` VARCHAR(191) NOT NULL,
|
||||
`activation_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `license_renew_charge_transaction` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`activation_expires_at` DATETIME(3) NOT NULL,
|
||||
`tracking_code` VARCHAR(191) NOT NULL,
|
||||
`purchased_count` INTEGER NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`partner_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `license_renew_charge_transaction_tracking_code_key`(`tracking_code`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `partner_account_quota_charge_transaction` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`purchased_count` INTEGER NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`partner_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `partner_account_quota_allocation` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`charge_transaction_id` VARCHAR(191) NOT NULL,
|
||||
`license_id` VARCHAR(191) NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX `consumers_mobile_number_partner_id_key` ON `consumers`(`mobile_number`, `partner_id`);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX `consumers_national_code_partner_id_key` ON `consumers`(`national_code`, `partner_id`);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `licenses` ADD CONSTRAINT `licenses_charge_transaction_id_fkey` FOREIGN KEY (`charge_transaction_id`) REFERENCES `license_charged_transactions`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `licenses_activated` ADD CONSTRAINT `licenses_activated_license_id_fkey` FOREIGN KEY (`license_id`) REFERENCES `licenses`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `licenses_activated` ADD CONSTRAINT `licenses_activated_business_activity_id_fkey` FOREIGN KEY (`business_activity_id`) REFERENCES `business_activities`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `license_charged_transactions` ADD CONSTRAINT `license_charged_transactions_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `license_renew` ADD CONSTRAINT `license_renew_charge_transaction_id_fkey` FOREIGN KEY (`charge_transaction_id`) REFERENCES `license_renew_charge_transaction`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `license_renew` ADD CONSTRAINT `license_renew_activation_id_fkey` FOREIGN KEY (`activation_id`) REFERENCES `licenses_activated`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `license_renew_charge_transaction` ADD CONSTRAINT `license_renew_charge_transaction_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `partner_account_quota_charge_transaction` ADD CONSTRAINT `partner_account_quota_charge_transaction_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `partner_account_quota_allocation` ADD CONSTRAINT `partner_account_quota_allocation_charge_transaction_id_fkey` FOREIGN KEY (`charge_transaction_id`) REFERENCES `partner_account_quota_charge_transaction`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `partner_account_quota_allocation` ADD CONSTRAINT `partner_account_quota_allocation_license_id_fkey` FOREIGN KEY (`license_id`) REFERENCES `licenses`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -1,18 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[tracking_code]` on the table `partner_account_quota_charge_transaction` will be added. If there are existing duplicate values, this will fail.
|
||||
- Added the required column `expires_at` to the `license_renew` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `activation_expires_at` to the `partner_account_quota_charge_transaction` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `tracking_code` to the `partner_account_quota_charge_transaction` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE `license_renew` ADD COLUMN `expires_at` DATETIME(3) NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `partner_account_quota_charge_transaction` ADD COLUMN `activation_expires_at` DATETIME(3) NOT NULL,
|
||||
ADD COLUMN `tracking_code` VARCHAR(191) NOT NULL;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX `partner_account_quota_charge_transaction_tracking_code_key` ON `partner_account_quota_charge_transaction`(`tracking_code`);
|
||||
@@ -1,16 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `serial` on the `poses` table. All the data in the column will be lost.
|
||||
- A unique constraint covering the columns `[serial_number]` on the table `poses` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- DropIndex
|
||||
DROP INDEX `poses_serial_key` ON `poses`;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `poses` DROP COLUMN `serial`,
|
||||
ADD COLUMN `serial_number` VARCHAR(191) NULL;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX `poses_serial_number_key` ON `poses`(`serial_number`);
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[account_id]` on the table `poses` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE `licenses` MODIFY `accounts_limit` INTEGER NOT NULL DEFAULT 2;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `partners` ADD COLUMN `logo_url` VARCHAR(191) NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `poses` ADD COLUMN `account_id` VARCHAR(191) NULL;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX `poses_account_id_key` ON `poses`(`account_id`);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `poses` ADD CONSTRAINT `poses_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `consumer_accounts`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the `partner_account_quota_allocation` table. If the table is not empty, all the data it contains will be lost.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `partner_account_quota_allocation` DROP FOREIGN KEY `partner_account_quota_allocation_charge_transaction_id_fkey`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `partner_account_quota_allocation` DROP FOREIGN KEY `partner_account_quota_allocation_license_id_fkey`;
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE `partner_account_quota_allocation`;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `partner_account_quota_credit` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`charge_transaction_id` VARCHAR(191) NOT NULL,
|
||||
`allocation_id` VARCHAR(191) NULL,
|
||||
|
||||
UNIQUE INDEX `partner_account_quota_credit_allocation_id_key`(`allocation_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `license_account_allocation` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`license_activation_id` VARCHAR(191) NOT NULL,
|
||||
`account_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `license_account_allocation_account_id_key`(`account_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `partner_account_quota_credit` ADD CONSTRAINT `partner_account_quota_credit_charge_transaction_id_fkey` FOREIGN KEY (`charge_transaction_id`) REFERENCES `partner_account_quota_charge_transaction`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `partner_account_quota_credit` ADD CONSTRAINT `partner_account_quota_credit_allocation_id_fkey` FOREIGN KEY (`allocation_id`) REFERENCES `license_account_allocation`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `license_account_allocation` ADD CONSTRAINT `license_account_allocation_license_activation_id_fkey` FOREIGN KEY (`license_activation_id`) REFERENCES `licenses_activated`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `license_account_allocation` ADD CONSTRAINT `license_account_allocation_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `consumer_accounts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@@ -1,30 +0,0 @@
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `license_account_allocation` DROP FOREIGN KEY `license_account_allocation_account_id_fkey`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `license_account_allocation` DROP FOREIGN KEY `license_account_allocation_license_activation_id_fkey`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `partner_account_quota_credit` DROP FOREIGN KEY `partner_account_quota_credit_charge_transaction_id_fkey`;
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX `license_account_allocation_license_activation_id_fkey` ON `license_account_allocation`;
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX `partner_account_quota_credit_charge_transaction_id_fkey` ON `partner_account_quota_credit`;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `license_account_allocation` MODIFY `license_activation_id` VARCHAR(191) NULL,
|
||||
MODIFY `account_id` VARCHAR(191) NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `partner_account_quota_credit` MODIFY `charge_transaction_id` VARCHAR(191) NULL;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `partner_account_quota_credit` ADD CONSTRAINT `partner_account_quota_credit_charge_transaction_id_fkey` FOREIGN KEY (`charge_transaction_id`) REFERENCES `partner_account_quota_charge_transaction`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `license_account_allocation` ADD CONSTRAINT `license_account_allocation_license_activation_id_fkey` FOREIGN KEY (`license_activation_id`) REFERENCES `licenses_activated`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `license_account_allocation` ADD CONSTRAINT `license_account_allocation_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `consumer_accounts`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `allocation_id` on the `partner_account_quota_credit` table. All the data in the column will be lost.
|
||||
- A unique constraint covering the columns `[economic_code,consumer_id]` on the table `business_activities` will be added. If there are existing duplicate values, this will fail.
|
||||
- A unique constraint covering the columns `[credit_id]` on the table `license_account_allocation` will be added. If there are existing duplicate values, this will fail.
|
||||
- Made the column `account_id` on table `poses` required. This step will fail if there are existing NULL values in that column.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `license_renew` DROP FOREIGN KEY `license_renew_activation_id_fkey`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `partner_account_quota_credit` DROP FOREIGN KEY `partner_account_quota_credit_allocation_id_fkey`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `poses` DROP FOREIGN KEY `poses_account_id_fkey`;
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX `business_activities_economic_code_key` ON `business_activities`;
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX `license_renew_activation_id_fkey` ON `license_renew`;
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX `partner_account_quota_credit_allocation_id_key` ON `partner_account_quota_credit`;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `license_account_allocation` ADD COLUMN `credit_id` VARCHAR(191) NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `license_renew` MODIFY `activation_id` VARCHAR(191) NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `partner_account_quota_credit` DROP COLUMN `allocation_id`;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `poses` MODIFY `account_id` VARCHAR(191) NOT NULL;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX `business_activities_economic_code_consumer_id_key` ON `business_activities`(`economic_code`, `consumer_id`);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX `license_account_allocation_credit_id_key` ON `license_account_allocation`(`credit_id`);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `poses` ADD CONSTRAINT `poses_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `consumer_accounts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `license_renew` ADD CONSTRAINT `license_renew_activation_id_fkey` FOREIGN KEY (`activation_id`) REFERENCES `licenses_activated`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `license_account_allocation` ADD CONSTRAINT `license_account_allocation_credit_id_fkey` FOREIGN KEY (`credit_id`) REFERENCES `partner_account_quota_credit`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `complex_id` on the `customer_individuals` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `complex_id` on the `customer_legal` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `unknown_customer` on the `customers` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `complex_id` on the `goods` table. All the data in the column will be lost.
|
||||
- A unique constraint covering the columns `[business_activity_id,national_id]` on the table `customer_individuals` will be added. If there are existing duplicate values, this will fail.
|
||||
- A unique constraint covering the columns `[business_activity_id,economic_code]` on the table `customer_legal` will be added. If there are existing duplicate values, this will fail.
|
||||
- Added the required column `business_activity_id` to the `customer_individuals` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `mobile_number` to the `customer_individuals` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `business_activity_id` to the `customer_legal` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `customer_individuals` DROP FOREIGN KEY `customer_individuals_complex_id_fkey`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `customer_legal` DROP FOREIGN KEY `customer_legal_complex_id_fkey`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `goods` DROP FOREIGN KEY `goods_complex_id_fkey`;
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX `customer_individuals_complex_id_idx` ON `customer_individuals`;
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX `customer_individuals_complex_id_national_id_key` ON `customer_individuals`;
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX `customer_legal_complex_id_idx` ON `customer_legal`;
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX `customer_legal_complex_id_registration_number_key` ON `customer_legal`;
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX `goods_complex_id_fkey` ON `goods`;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `customer_individuals` DROP COLUMN `complex_id`,
|
||||
ADD COLUMN `business_activity_id` VARCHAR(191) NOT NULL,
|
||||
ADD COLUMN `mobile_number` CHAR(15) NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `customer_legal` DROP COLUMN `complex_id`,
|
||||
ADD COLUMN `business_activity_id` VARCHAR(191) NOT NULL,
|
||||
MODIFY `registration_number` CHAR(20) NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `customers` DROP COLUMN `unknown_customer`;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `goods` DROP COLUMN `complex_id`,
|
||||
ADD COLUMN `business_activity_id` VARCHAR(191) NULL;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX `customer_individuals_business_activity_id_idx` ON `customer_individuals`(`business_activity_id`);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX `customer_individuals_business_activity_id_national_id_key` ON `customer_individuals`(`business_activity_id`, `national_id`);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX `customer_legal_business_activity_id_idx` ON `customer_legal`(`business_activity_id`);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX `customer_legal_business_activity_id_economic_code_key` ON `customer_legal`(`business_activity_id`, `economic_code`);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `customer_individuals` ADD CONSTRAINT `customer_individuals_business_activity_id_fkey` FOREIGN KEY (`business_activity_id`) REFERENCES `business_activities`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `customer_legal` ADD CONSTRAINT `customer_legal_business_activity_id_fkey` FOREIGN KEY (`business_activity_id`) REFERENCES `business_activities`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `goods` ADD CONSTRAINT `goods_business_activity_id_fkey` FOREIGN KEY (`business_activity_id`) REFERENCES `business_activities`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -1,102 +0,0 @@
|
||||
/*
|
||||
Consumer profile split migration.
|
||||
|
||||
Existing profile data is copied into `individual_consumers` before the source
|
||||
columns are removed from `consumers`.
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE `consumers`
|
||||
ADD COLUMN `type` ENUM('INDIVIDUAL', 'LEGAL') NOT NULL DEFAULT 'INDIVIDUAL';
|
||||
|
||||
UPDATE `consumers` SET `type` = 'INDIVIDUAL';
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `consumers` DROP FOREIGN KEY `consumers_partner_id_fkey`;
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX `consumers_mobile_number_partner_id_key` ON `consumers`;
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX `consumers_national_code_partner_id_key` ON `consumers`;
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX `consumers_partner_id_fkey` ON `consumers`;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `individual_consumers` (
|
||||
`first_name` VARCHAR(191) NOT NULL,
|
||||
`last_name` VARCHAR(191) NOT NULL,
|
||||
`mobile_number` VARCHAR(191) NOT NULL,
|
||||
`national_code` VARCHAR(191) NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`partner_id` VARCHAR(191) NOT NULL,
|
||||
`consumer_id` VARCHAR(191) NOT NULL,
|
||||
UNIQUE INDEX `individual_consumers_mobile_number_consumer_id_key` (
|
||||
`mobile_number`,
|
||||
`consumer_id`
|
||||
),
|
||||
UNIQUE INDEX `individual_consumers_partner_id_national_code_key` (`partner_id`, `national_code`),
|
||||
PRIMARY KEY (`consumer_id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `legal_consumers` (
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`registration_code` VARCHAR(191) NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`partner_id` VARCHAR(191) NOT NULL,
|
||||
`consumer_id` VARCHAR(191) NOT NULL,
|
||||
UNIQUE INDEX `legal_consumers_partner_id_registration_code_key` (
|
||||
`partner_id`,
|
||||
`registration_code`
|
||||
),
|
||||
PRIMARY KEY (`consumer_id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
INSERT INTO
|
||||
`individual_consumers` (
|
||||
`first_name`,
|
||||
`last_name`,
|
||||
`mobile_number`,
|
||||
`national_code`,
|
||||
`created_at`,
|
||||
`updated_at`,
|
||||
`partner_id`,
|
||||
`consumer_id`
|
||||
)
|
||||
SELECT
|
||||
`first_name`,
|
||||
`last_name`,
|
||||
`mobile_number`,
|
||||
`national_code`,
|
||||
`created_at`,
|
||||
`updated_at`,
|
||||
`partner_id`,
|
||||
`id`
|
||||
FROM `consumers`;
|
||||
|
||||
ALTER TABLE `consumers`
|
||||
DROP COLUMN `first_name`,
|
||||
DROP COLUMN `last_name`,
|
||||
DROP COLUMN `mobile_number`,
|
||||
DROP COLUMN `national_code`,
|
||||
DROP COLUMN `partner_id`,
|
||||
MODIFY `type` ENUM('INDIVIDUAL', 'LEGAL') NOT NULL;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `individual_consumers`
|
||||
ADD CONSTRAINT `individual_consumers_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `individual_consumers`
|
||||
ADD CONSTRAINT `individual_consumers_consumer_id_fkey` FOREIGN KEY (`consumer_id`) REFERENCES `consumers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `legal_consumers`
|
||||
ADD CONSTRAINT `legal_consumers_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `legal_consumers`
|
||||
ADD CONSTRAINT `legal_consumers_consumer_id_fkey` FOREIGN KEY (`consumer_id`) REFERENCES `consumers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -1,22 +0,0 @@
|
||||
ALTER TABLE `individual_consumers` RENAME TO `consumers_individual`;
|
||||
ALTER TABLE `legal_consumers` RENAME TO `consumers_legal`;
|
||||
|
||||
ALTER TABLE `consumers_individual`
|
||||
RENAME INDEX `individual_consumers_mobile_number_consumer_id_key` TO `consumers_individual_mobile_number_consumer_id_key`;
|
||||
ALTER TABLE `consumers_individual`
|
||||
RENAME INDEX `individual_consumers_partner_id_national_code_key` TO `consumers_individual_partner_id_national_code_key`;
|
||||
ALTER TABLE `consumers_legal`
|
||||
RENAME INDEX `legal_consumers_partner_id_registration_code_key` TO `consumers_legal_partner_id_registration_code_key`;
|
||||
|
||||
ALTER TABLE `consumers_individual` DROP FOREIGN KEY `individual_consumers_partner_id_fkey`;
|
||||
ALTER TABLE `consumers_individual` DROP FOREIGN KEY `individual_consumers_consumer_id_fkey`;
|
||||
ALTER TABLE `consumers_legal` DROP FOREIGN KEY `legal_consumers_partner_id_fkey`;
|
||||
ALTER TABLE `consumers_legal` DROP FOREIGN KEY `legal_consumers_consumer_id_fkey`;
|
||||
|
||||
ALTER TABLE `consumers_individual`
|
||||
ADD CONSTRAINT `consumers_individual_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||
ADD CONSTRAINT `consumers_individual_consumer_id_fkey` FOREIGN KEY (`consumer_id`) REFERENCES `consumers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE `consumers_legal`
|
||||
ADD CONSTRAINT `consumers_legal_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||
ADD CONSTRAINT `consumers_legal_consumer_id_fkey` FOREIGN KEY (`consumer_id`) REFERENCES `consumers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `account_id` on the `sales_invoices` table. All the data in the column will be lost.
|
||||
- A unique constraint covering the columns `[invoice_number,pos_id]` on the table `sales_invoices` will be added. If there are existing duplicate values, this will fail.
|
||||
- Added the required column `fiscal_id` to the `business_activities` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `partner_token` to the `business_activities` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `consumer_account_id` to the `sales_invoices` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `invoice_number` to the `sales_invoices` table without a default value. This is not possible if the table is not empty.
|
||||
- Made the column `invoice_date` on table `sales_invoices` required. This step will fail if there are existing NULL values in that column.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `sales_invoices` DROP FOREIGN KEY `sales_invoices_account_id_fkey`;
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX `sales_invoices_account_id_fkey` ON `sales_invoices`;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `business_activities` ADD COLUMN `fiscal_id` VARCHAR(191) NOT NULL DEFAULT '',
|
||||
ADD COLUMN `partner_token` VARCHAR(191) NOT NULL DEFAULT '';
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `sales_invoice_items` ADD COLUMN `good_snapshot` JSON NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `sales_invoice_payments` MODIFY `paid_at` TIMESTAMP(0) NOT NULL,
|
||||
MODIFY `created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0);
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `sales_invoices` DROP COLUMN `account_id`,
|
||||
ADD COLUMN `consumer_account_id` VARCHAR(191) NOT NULL,
|
||||
ADD COLUMN `invoice_number` INTEGER NOT NULL,
|
||||
MODIFY `invoice_date` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `sale_invoice_fiscals` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`retry_count` INTEGER NOT NULL DEFAULT 0,
|
||||
`last_attempt_at` TIMESTAMP(0) NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`invoice_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `sale_invoice_fiscals_invoice_id_key`(`invoice_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `sale_invoice_fiscal_attempts` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`attempt_no` INTEGER NOT NULL,
|
||||
`status` VARCHAR(50) NOT NULL,
|
||||
`tax_id` VARCHAR(191) NULL,
|
||||
`request_payload` JSON NULL,
|
||||
`response_payload` JSON NULL,
|
||||
`error_message` TEXT NULL,
|
||||
`sent_at` TIMESTAMP(0) NULL,
|
||||
`received_at` TIMESTAMP(0) NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`fiscal_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `sale_invoice_fiscal_attempts_tax_id_key`(`tax_id`),
|
||||
INDEX `sale_invoice_fiscal_attempts_status_idx`(`status`),
|
||||
INDEX `sale_invoice_fiscal_attempts_tax_id_idx`(`tax_id`),
|
||||
UNIQUE INDEX `sale_invoice_fiscal_attempts_fiscal_id_attempt_no_key`(`fiscal_id`, `attempt_no`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX `sales_invoices_invoice_number_pos_id_key` ON `sales_invoices`(`invoice_number`, `pos_id`);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `sales_invoices` ADD CONSTRAINT `sales_invoices_consumer_account_id_fkey` FOREIGN KEY (`consumer_account_id`) REFERENCES `consumer_accounts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `sale_invoice_fiscals` ADD CONSTRAINT `sale_invoice_fiscals_invoice_id_fkey` FOREIGN KEY (`invoice_id`) REFERENCES `sales_invoices`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `sale_invoice_fiscal_attempts` ADD CONSTRAINT `sale_invoice_fiscal_attempts_fiscal_id_fkey` FOREIGN KEY (`fiscal_id`) REFERENCES `sale_invoice_fiscals`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -1,3 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE `business_activities` ALTER COLUMN `fiscal_id` DROP DEFAULT,
|
||||
ALTER COLUMN `partner_token` DROP DEFAULT;
|
||||
@@ -1,2 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE `partners` ADD COLUMN `fiscal_switch_type` ENUM('NAMA', 'SUN') NOT NULL DEFAULT 'NAMA';
|
||||
+470
-176
@@ -37,76 +37,6 @@ CREATE TABLE `accounts` (
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `consumer_accounts` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`role` ENUM('OWNER', 'MANAGER', 'OPERATOR') NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`consumer_id` VARCHAR(191) NOT NULL,
|
||||
`account_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `consumer_accounts_account_id_key`(`account_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `consumers` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`mobile_number` VARCHAR(191) NOT NULL,
|
||||
`first_name` VARCHAR(191) NOT NULL,
|
||||
`last_name` VARCHAR(191) NOT NULL,
|
||||
`status` ENUM('ACTIVE', 'SUSPENDED') NOT NULL DEFAULT 'ACTIVE',
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `consumers_mobile_number_key`(`mobile_number`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `business_activities` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`guild_id` VARCHAR(191) NOT NULL,
|
||||
`consumer_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `complexes` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`address` VARCHAR(191) NULL,
|
||||
`tax_id` VARCHAR(191) NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`business_activity_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `poses` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`serial` VARCHAR(191) NOT NULL,
|
||||
`model` VARCHAR(191) NULL,
|
||||
`status` ENUM('ACTIVE', 'DISABLED') NOT NULL DEFAULT 'ACTIVE',
|
||||
`pos_type` ENUM('PSP', 'MOBILE', 'WEB', 'API') NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`complex_id` VARCHAR(191) NOT NULL,
|
||||
`device_id` VARCHAR(191) NULL,
|
||||
`provider_id` VARCHAR(191) NULL,
|
||||
|
||||
UNIQUE INDEX `poses_serial_key`(`serial`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `device_brands` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
@@ -129,18 +59,108 @@ CREATE TABLE `devices` (
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `license_charged_transactions` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`activation_expires_at` DATETIME(3) NOT NULL,
|
||||
`tracking_code` VARCHAR(191) NOT NULL,
|
||||
`purchased_count` INTEGER NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`partner_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `license_charged_transactions_tracking_code_key`(`tracking_code`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `licenses` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`accounts_limit` INTEGER NOT NULL DEFAULT 2,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`charge_transaction_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `licenses_activated` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`starts_at` DATETIME(3) NOT NULL,
|
||||
`expires_at` DATETIME(3) NOT NULL,
|
||||
`status` ENUM('ACTIVE', 'EXPIRED', 'SUSPENDED') NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`partner_id` VARCHAR(191) NULL,
|
||||
`consumer_id` VARCHAR(191) NOT NULL,
|
||||
`license_id` VARCHAR(191) NOT NULL,
|
||||
`business_activity_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `licenses_consumer_id_key`(`consumer_id`),
|
||||
UNIQUE INDEX `licenses_activated_id_key`(`id`),
|
||||
UNIQUE INDEX `licenses_activated_license_id_key`(`license_id`),
|
||||
UNIQUE INDEX `licenses_activated_business_activity_id_key`(`business_activity_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `license_renew_charge_transaction` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`activation_expires_at` DATETIME(3) NOT NULL,
|
||||
`tracking_code` VARCHAR(191) NOT NULL,
|
||||
`purchased_count` INTEGER NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`partner_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `license_renew_charge_transaction_tracking_code_key`(`tracking_code`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `license_renew` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`expires_at` DATETIME(3) NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`charge_transaction_id` VARCHAR(191) NOT NULL,
|
||||
`activation_id` VARCHAR(191) NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `partner_account_quota_charge_transaction` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`activation_expires_at` DATETIME(3) NOT NULL,
|
||||
`tracking_code` VARCHAR(191) NOT NULL,
|
||||
`purchased_count` INTEGER NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`partner_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `partner_account_quota_charge_transaction_tracking_code_key`(`tracking_code`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `partner_account_quota_credit` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`charge_transaction_id` VARCHAR(191) NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `license_account_allocation` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`license_activation_id` VARCHAR(191) NULL,
|
||||
`account_id` VARCHAR(191) NULL,
|
||||
`credit_id` VARCHAR(191) NULL,
|
||||
|
||||
UNIQUE INDEX `license_account_allocation_account_id_key`(`account_id`),
|
||||
UNIQUE INDEX `license_account_allocation_credit_id_key`(`credit_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
@@ -162,8 +182,9 @@ CREATE TABLE `partners` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`code` VARCHAR(191) NOT NULL,
|
||||
`license_quota` INTEGER NULL DEFAULT 0,
|
||||
`status` ENUM('ACTIVE', 'SUSPENDED') NOT NULL DEFAULT 'ACTIVE',
|
||||
`fiscal_switch_type` ENUM('NAMA', 'SUN') NOT NULL,
|
||||
`logo_url` VARCHAR(191) NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
|
||||
@@ -240,75 +261,145 @@ CREATE TABLE `providers` (
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `trigger_logs` (
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`message` TEXT NOT NULL,
|
||||
`createdAt` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`name` TEXT NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `user_devices` (
|
||||
`account_id` VARCHAR(255) NULL,
|
||||
CREATE TABLE `consumer_devices` (
|
||||
`uuid` VARCHAR(255) NOT NULL,
|
||||
`app_version` VARCHAR(20) NOT NULL,
|
||||
`build_number` VARCHAR(20) NOT NULL,
|
||||
`uuid` VARCHAR(255) NOT NULL,
|
||||
`platform` VARCHAR(100) NOT NULL,
|
||||
`brand` VARCHAR(100) NOT NULL,
|
||||
`model` VARCHAR(100) NOT NULL,
|
||||
`device` VARCHAR(100) NOT NULL,
|
||||
`publisher` ENUM('DIRECT', 'CAFE_BAZAR', 'MAYKET') NOT NULL,
|
||||
`os_version` VARCHAR(20) NOT NULL,
|
||||
`sdk_version` VARCHAR(20) NOT NULL,
|
||||
`release_number` VARCHAR(20) NOT NULL,
|
||||
`user_agent` VARCHAR(100) NULL,
|
||||
`browser_name` VARCHAR(100) NULL,
|
||||
`fcm_token` VARCHAR(100) NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`consumer_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `user_devices_uuid_key`(`uuid`),
|
||||
UNIQUE INDEX `consumer_devices_uuid_key`(`uuid`),
|
||||
PRIMARY KEY (`uuid`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `customers` (
|
||||
CREATE TABLE `application_released_info` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`is_favorite` BOOLEAN NULL DEFAULT false,
|
||||
`version` VARCHAR(191) NOT NULL,
|
||||
`build_number` VARCHAR(191) NOT NULL,
|
||||
`is_minimum_supported` BOOLEAN NOT NULL DEFAULT false,
|
||||
`release_type` ENUM('STABLE', 'BETA', 'ALPHA') NOT NULL,
|
||||
`platform` ENUM('ANDROID', 'IOS') NOT NULL,
|
||||
`notes` JSON NULL,
|
||||
`release_date` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`deleted_at` TIMESTAMP(0) NULL,
|
||||
`type` ENUM('INDIVIDUAL', 'LEGAL', 'UNKNOWN') NOT NULL,
|
||||
`unknown_customer` JSON NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `customer_individuals` (
|
||||
`first_name` VARCHAR(255) NOT NULL,
|
||||
`last_name` VARCHAR(255) NOT NULL,
|
||||
`national_id` CHAR(10) NOT NULL,
|
||||
`postal_code` CHAR(10) NOT NULL,
|
||||
`economic_code` CHAR(10) NULL,
|
||||
`customer_id` VARCHAR(191) NOT NULL,
|
||||
`complex_id` VARCHAR(191) NOT NULL,
|
||||
CREATE TABLE `consumer_accounts` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`role` ENUM('OWNER', 'MANAGER', 'OPERATOR') NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`consumer_id` VARCHAR(191) NOT NULL,
|
||||
`account_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
INDEX `customer_individuals_complex_id_idx`(`complex_id`),
|
||||
UNIQUE INDEX `customer_individuals_complex_id_national_id_key`(`complex_id`, `national_id`),
|
||||
PRIMARY KEY (`customer_id`)
|
||||
UNIQUE INDEX `consumer_accounts_account_id_key`(`account_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `customer_legal` (
|
||||
`company_name` VARCHAR(255) NOT NULL,
|
||||
`economic_code` CHAR(10) NOT NULL,
|
||||
`registration_number` CHAR(20) NOT NULL,
|
||||
`postal_code` CHAR(10) NOT NULL,
|
||||
`customer_id` VARCHAR(191) NOT NULL,
|
||||
`complex_id` VARCHAR(191) NOT NULL,
|
||||
CREATE TABLE `consumers` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`type` ENUM('INDIVIDUAL', 'LEGAL') NOT NULL,
|
||||
`status` ENUM('ACTIVE', 'SUSPENDED') NOT NULL DEFAULT 'ACTIVE',
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
|
||||
INDEX `customer_legal_complex_id_idx`(`complex_id`),
|
||||
UNIQUE INDEX `customer_legal_complex_id_registration_number_key`(`complex_id`, `registration_number`),
|
||||
PRIMARY KEY (`customer_id`)
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `consumers_individual` (
|
||||
`first_name` VARCHAR(191) NOT NULL,
|
||||
`last_name` VARCHAR(191) NOT NULL,
|
||||
`mobile_number` VARCHAR(191) NOT NULL,
|
||||
`national_code` VARCHAR(191) NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`partner_id` VARCHAR(191) NOT NULL,
|
||||
`consumer_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `consumers_individual_mobile_number_consumer_id_key`(`mobile_number`, `consumer_id`),
|
||||
UNIQUE INDEX `consumers_individual_partner_id_national_code_key`(`partner_id`, `national_code`),
|
||||
PRIMARY KEY (`consumer_id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `consumers_legal` (
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`registration_code` VARCHAR(191) NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`partner_id` VARCHAR(191) NOT NULL,
|
||||
`consumer_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `consumers_legal_partner_id_registration_code_key`(`partner_id`, `registration_code`),
|
||||
PRIMARY KEY (`consumer_id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `business_activities` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`economic_code` VARCHAR(191) NOT NULL,
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`fiscal_id` VARCHAR(191) NOT NULL,
|
||||
`partner_token` VARCHAR(191) NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`guild_id` VARCHAR(191) NOT NULL,
|
||||
`consumer_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `business_activities_economic_code_consumer_id_key`(`economic_code`, `consumer_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `complexes` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`branch_code` VARCHAR(191) NOT NULL,
|
||||
`address` VARCHAR(191) NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`business_activity_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `poses` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`model` VARCHAR(191) NULL,
|
||||
`serial_number` VARCHAR(191) NULL,
|
||||
`status` ENUM('ACTIVE', 'DISABLED') NOT NULL DEFAULT 'ACTIVE',
|
||||
`pos_type` ENUM('PSP', 'MOBILE', 'WEB', 'API') NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`complex_id` VARCHAR(191) NOT NULL,
|
||||
`device_id` VARCHAR(191) NULL,
|
||||
`provider_id` VARCHAR(191) NULL,
|
||||
`account_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `poses_serial_number_key`(`serial_number`),
|
||||
UNIQUE INDEX `poses_account_id_key`(`account_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
@@ -316,18 +407,19 @@ CREATE TABLE `goods` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`is_default_guild_good` BOOLEAN NOT NULL DEFAULT false,
|
||||
`sku` VARCHAR(100) NOT NULL,
|
||||
`unit_type` ENUM('COUNT', 'GRAM', 'KILOGRAM', 'MILLILITER', 'LITER', 'METER', 'HOUR') NOT NULL,
|
||||
`pricing_model` ENUM('STANDARD', 'GOLD') NOT NULL,
|
||||
`description` TEXT NULL,
|
||||
`local_sku` VARCHAR(100) NULL,
|
||||
`barcode` VARCHAR(100) NULL,
|
||||
`base_sale_price` DECIMAL(15, 0) NULL DEFAULT 0.00,
|
||||
`image_url` VARCHAR(255) NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`deleted_at` TIMESTAMP(0) NULL,
|
||||
`complex_id` VARCHAR(191) NULL,
|
||||
`sku_id` VARCHAR(191) NOT NULL,
|
||||
`measure_unit_id` VARCHAR(191) NOT NULL,
|
||||
`category_id` VARCHAR(191) NULL,
|
||||
`business_activity_id` VARCHAR(191) NULL,
|
||||
|
||||
UNIQUE INDEX `goods_local_sku_key`(`local_sku`),
|
||||
UNIQUE INDEX `goods_barcode_key`(`barcode`),
|
||||
@@ -351,6 +443,87 @@ CREATE TABLE `good_categories` (
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `measure_units` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`code` VARCHAR(191) NOT NULL,
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
|
||||
UNIQUE INDEX `measure_units_code_key`(`code`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `stock_keeping_units` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`code` VARCHAR(191) NOT NULL,
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`VAT` DECIMAL(5, 2) NOT NULL,
|
||||
`type` ENUM('GOLD') NOT NULL DEFAULT 'GOLD',
|
||||
`is_public` BOOLEAN NOT NULL DEFAULT true,
|
||||
`is_domestic` BOOLEAN NOT NULL DEFAULT false,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `stock_keeping_units_code_key`(`code`),
|
||||
INDEX `stock_keeping_units_code_idx`(`code`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `trigger_logs` (
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`message` TEXT NOT NULL,
|
||||
`createdAt` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`name` TEXT NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `customers` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`is_favorite` BOOLEAN NULL DEFAULT false,
|
||||
`type` ENUM('INDIVIDUAL', 'LEGAL', 'UNKNOWN') NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`deleted_at` TIMESTAMP(0) NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `customer_individuals` (
|
||||
`first_name` VARCHAR(255) NOT NULL,
|
||||
`last_name` VARCHAR(255) NOT NULL,
|
||||
`national_id` CHAR(10) NOT NULL,
|
||||
`mobile_number` CHAR(15) NOT NULL,
|
||||
`postal_code` CHAR(10) NOT NULL,
|
||||
`economic_code` CHAR(10) NULL,
|
||||
`customer_id` VARCHAR(191) NOT NULL,
|
||||
`business_activity_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
INDEX `customer_individuals_business_activity_id_idx`(`business_activity_id`),
|
||||
UNIQUE INDEX `customer_individuals_business_activity_id_national_id_key`(`business_activity_id`, `national_id`),
|
||||
PRIMARY KEY (`customer_id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `customer_legal` (
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`economic_code` CHAR(10) NOT NULL,
|
||||
`registration_number` CHAR(20) NULL,
|
||||
`postal_code` CHAR(10) NOT NULL,
|
||||
`customer_id` VARCHAR(191) NOT NULL,
|
||||
`business_activity_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
INDEX `customer_legal_business_activity_id_idx`(`business_activity_id`),
|
||||
UNIQUE INDEX `customer_legal_business_activity_id_economic_code_key`(`business_activity_id`, `economic_code`),
|
||||
PRIMARY KEY (`customer_id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `guilds` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
@@ -367,16 +540,18 @@ CREATE TABLE `sales_invoices` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`code` VARCHAR(100) NOT NULL,
|
||||
`total_amount` DECIMAL(15, 2) NOT NULL,
|
||||
`invoice_number` INTEGER NOT NULL,
|
||||
`invoice_date` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`notes` TEXT NULL,
|
||||
`unknown_customer` JSON NULL,
|
||||
`invoice_date` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`customer_id` VARCHAR(191) NULL,
|
||||
`account_id` VARCHAR(191) NOT NULL,
|
||||
`consumer_account_id` VARCHAR(191) NOT NULL,
|
||||
`pos_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `sales_invoices_code_key`(`code`),
|
||||
UNIQUE INDEX `sales_invoices_invoice_number_pos_id_key`(`invoice_number`, `pos_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
@@ -384,34 +559,90 @@ CREATE TABLE `sales_invoices` (
|
||||
CREATE TABLE `sales_invoice_items` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`quantity` DECIMAL(10, 0) NOT NULL,
|
||||
`unit_type` ENUM('COUNT', 'GRAM', 'KILOGRAM', 'MILLILITER', 'LITER', 'METER', 'HOUR') NOT NULL,
|
||||
`measure_unit_text` VARCHAR(50) NOT NULL,
|
||||
`measure_unit_code` VARCHAR(50) NOT NULL,
|
||||
`sku_code` VARCHAR(50) NOT NULL,
|
||||
`sku_vat` DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
|
||||
`unit_price` DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
|
||||
`total_amount` DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`discount` DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
|
||||
`notes` TEXT NULL,
|
||||
`payload` JSON NULL,
|
||||
`good_snapshot` JSON NULL,
|
||||
`invoice_id` VARCHAR(191) NOT NULL,
|
||||
`good_id` VARCHAR(191) NULL,
|
||||
`service_id` VARCHAR(191) NULL,
|
||||
`payload` JSON NULL,
|
||||
|
||||
INDEX `sales_invoice_items_invoice_id_good_id_idx`(`invoice_id`, `good_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `sale_invoice_fiscals` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`retry_count` INTEGER NOT NULL DEFAULT 0,
|
||||
`last_attempt_at` TIMESTAMP(0) NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`invoice_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `sale_invoice_fiscals_invoice_id_key`(`invoice_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `sale_invoice_fiscal_attempts` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`attempt_no` INTEGER NOT NULL,
|
||||
`status` ENUM('SUCCESS', 'FAILURE', 'NOT_SEND', 'QUEUED') NOT NULL,
|
||||
`tax_id` VARCHAR(191) NULL,
|
||||
`type` ENUM('MAIN', 'UPDATE', 'REVOKE', 'REMOVE') NOT NULL,
|
||||
`request_payload` JSON NULL,
|
||||
`response_payload` JSON NULL,
|
||||
`error_message` TEXT NULL,
|
||||
`sent_at` TIMESTAMP(0) NULL,
|
||||
`received_at` TIMESTAMP(0) NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`fiscal_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `sale_invoice_fiscal_attempts_tax_id_key`(`tax_id`),
|
||||
INDEX `sale_invoice_fiscal_attempts_status_idx`(`status`),
|
||||
INDEX `sale_invoice_fiscal_attempts_tax_id_idx`(`tax_id`),
|
||||
UNIQUE INDEX `sale_invoice_fiscal_attempts_fiscal_id_attempt_no_key`(`fiscal_id`, `attempt_no`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `sales_invoice_payments` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`invoice_id` VARCHAR(191) NOT NULL,
|
||||
`amount` DECIMAL(15, 2) NOT NULL,
|
||||
`payment_method` ENUM('TERMINAL', 'CASH', 'SET_OFF', 'CARD', 'BANK', 'CHECK', 'OTHER') NOT NULL,
|
||||
`paid_at` DATETIME(3) NOT NULL,
|
||||
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`paid_at` TIMESTAMP(0) NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`invoice_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
INDEX `sales_invoice_payments_invoice_id_idx`(`invoice_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `sales_invoice_payment_terminal_info` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`terminal_id` VARCHAR(191) NOT NULL,
|
||||
`stan` VARCHAR(191) NOT NULL,
|
||||
`rrn` VARCHAR(191) NOT NULL,
|
||||
`transaction_date_time` DATETIME(3) NOT NULL,
|
||||
`customer_card_no` VARCHAR(191) NULL,
|
||||
`description` VARCHAR(191) NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`payment_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `sales_invoice_payment_terminal_info_payment_id_key`(`payment_id`),
|
||||
UNIQUE INDEX `sales_invoice_payment_terminal_info_terminal_id_stan_rrn_pay_key`(`terminal_id`, `stan`, `rrn`, `payment_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `services` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
@@ -456,12 +687,99 @@ ALTER TABLE `admin_accounts` ADD CONSTRAINT `admin_accounts_admin_id_fkey` FOREI
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `admin_accounts` ADD CONSTRAINT `admin_accounts_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `devices` ADD CONSTRAINT `devices_brand_id_fkey` FOREIGN KEY (`brand_id`) REFERENCES `device_brands`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `license_charged_transactions` ADD CONSTRAINT `license_charged_transactions_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `licenses` ADD CONSTRAINT `licenses_charge_transaction_id_fkey` FOREIGN KEY (`charge_transaction_id`) REFERENCES `license_charged_transactions`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `licenses_activated` ADD CONSTRAINT `licenses_activated_license_id_fkey` FOREIGN KEY (`license_id`) REFERENCES `licenses`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `licenses_activated` ADD CONSTRAINT `licenses_activated_business_activity_id_fkey` FOREIGN KEY (`business_activity_id`) REFERENCES `business_activities`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `license_renew_charge_transaction` ADD CONSTRAINT `license_renew_charge_transaction_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `license_renew` ADD CONSTRAINT `license_renew_charge_transaction_id_fkey` FOREIGN KEY (`charge_transaction_id`) REFERENCES `license_renew_charge_transaction`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `license_renew` ADD CONSTRAINT `license_renew_activation_id_fkey` FOREIGN KEY (`activation_id`) REFERENCES `licenses_activated`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `partner_account_quota_charge_transaction` ADD CONSTRAINT `partner_account_quota_charge_transaction_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `partner_account_quota_credit` ADD CONSTRAINT `partner_account_quota_credit_charge_transaction_id_fkey` FOREIGN KEY (`charge_transaction_id`) REFERENCES `partner_account_quota_charge_transaction`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `license_account_allocation` ADD CONSTRAINT `license_account_allocation_license_activation_id_fkey` FOREIGN KEY (`license_activation_id`) REFERENCES `licenses_activated`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `license_account_allocation` ADD CONSTRAINT `license_account_allocation_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `consumer_accounts`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `license_account_allocation` ADD CONSTRAINT `license_account_allocation_credit_id_fkey` FOREIGN KEY (`credit_id`) REFERENCES `partner_account_quota_credit`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `partner_accounts` ADD CONSTRAINT `partner_accounts_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `partner_accounts` ADD CONSTRAINT `partner_accounts_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `permission_consumers` ADD CONSTRAINT `permission_consumers_consumer_account_id_fkey` FOREIGN KEY (`consumer_account_id`) REFERENCES `consumer_accounts`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `permission_poses` ADD CONSTRAINT `permission_poses_pos_id_fkey` FOREIGN KEY (`pos_id`) REFERENCES `poses`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `permission_poses` ADD CONSTRAINT `permission_poses_permission_id_fkey` FOREIGN KEY (`permission_id`) REFERENCES `permission_consumers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `permission_complexes` ADD CONSTRAINT `permission_complexes_complex_id_fkey` FOREIGN KEY (`complex_id`) REFERENCES `complexes`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `permission_complexes` ADD CONSTRAINT `permission_complexes_permission_id_fkey` FOREIGN KEY (`permission_id`) REFERENCES `permission_consumers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `permission_business_activities` ADD CONSTRAINT `permission_business_activities_business_id_fkey` FOREIGN KEY (`business_id`) REFERENCES `business_activities`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `permission_business_activities` ADD CONSTRAINT `permission_business_activities_permission_id_fkey` FOREIGN KEY (`permission_id`) REFERENCES `permission_consumers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `provider_accounts` ADD CONSTRAINT `provider_accounts_provider_id_fkey` FOREIGN KEY (`provider_id`) REFERENCES `providers`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `provider_accounts` ADD CONSTRAINT `provider_accounts_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `consumer_devices` ADD CONSTRAINT `consumer_devices_consumer_id_fkey` FOREIGN KEY (`consumer_id`) REFERENCES `consumers`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `consumer_accounts` ADD CONSTRAINT `consumer_accounts_consumer_id_fkey` FOREIGN KEY (`consumer_id`) REFERENCES `consumers`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `consumer_accounts` ADD CONSTRAINT `consumer_accounts_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `consumers_individual` ADD CONSTRAINT `consumers_individual_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `consumers_individual` ADD CONSTRAINT `consumers_individual_consumer_id_fkey` FOREIGN KEY (`consumer_id`) REFERENCES `consumers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `consumers_legal` ADD CONSTRAINT `consumers_legal_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `consumers_legal` ADD CONSTRAINT `consumers_legal_consumer_id_fkey` FOREIGN KEY (`consumer_id`) REFERENCES `consumers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `business_activities` ADD CONSTRAINT `business_activities_guild_id_fkey` FOREIGN KEY (`guild_id`) REFERENCES `guilds`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
@@ -481,64 +799,19 @@ ALTER TABLE `poses` ADD CONSTRAINT `poses_device_id_fkey` FOREIGN KEY (`device_i
|
||||
ALTER TABLE `poses` ADD CONSTRAINT `poses_provider_id_fkey` FOREIGN KEY (`provider_id`) REFERENCES `providers`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `devices` ADD CONSTRAINT `devices_brand_id_fkey` FOREIGN KEY (`brand_id`) REFERENCES `device_brands`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `poses` ADD CONSTRAINT `poses_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `consumer_accounts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `licenses` ADD CONSTRAINT `licenses_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
ALTER TABLE `goods` ADD CONSTRAINT `goods_sku_id_fkey` FOREIGN KEY (`sku_id`) REFERENCES `stock_keeping_units`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `licenses` ADD CONSTRAINT `licenses_consumer_id_fkey` FOREIGN KEY (`consumer_id`) REFERENCES `consumers`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `partner_accounts` ADD CONSTRAINT `partner_accounts_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `partner_accounts` ADD CONSTRAINT `partner_accounts_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `permission_consumers` ADD CONSTRAINT `permission_consumers_consumer_account_id_fkey` FOREIGN KEY (`consumer_account_id`) REFERENCES `consumer_accounts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `permission_poses` ADD CONSTRAINT `permission_poses_pos_id_fkey` FOREIGN KEY (`pos_id`) REFERENCES `poses`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `permission_poses` ADD CONSTRAINT `permission_poses_permission_id_fkey` FOREIGN KEY (`permission_id`) REFERENCES `permission_consumers`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `permission_complexes` ADD CONSTRAINT `permission_complexes_complex_id_fkey` FOREIGN KEY (`complex_id`) REFERENCES `complexes`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `permission_complexes` ADD CONSTRAINT `permission_complexes_permission_id_fkey` FOREIGN KEY (`permission_id`) REFERENCES `permission_consumers`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `permission_business_activities` ADD CONSTRAINT `permission_business_activities_business_id_fkey` FOREIGN KEY (`business_id`) REFERENCES `business_activities`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `permission_business_activities` ADD CONSTRAINT `permission_business_activities_permission_id_fkey` FOREIGN KEY (`permission_id`) REFERENCES `permission_consumers`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `provider_accounts` ADD CONSTRAINT `provider_accounts_provider_id_fkey` FOREIGN KEY (`provider_id`) REFERENCES `providers`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `provider_accounts` ADD CONSTRAINT `provider_accounts_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `customer_individuals` ADD CONSTRAINT `customer_individuals_customer_id_fkey` FOREIGN KEY (`customer_id`) REFERENCES `customers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `customer_individuals` ADD CONSTRAINT `customer_individuals_complex_id_fkey` FOREIGN KEY (`complex_id`) REFERENCES `complexes`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `customer_legal` ADD CONSTRAINT `customer_legal_customer_id_fkey` FOREIGN KEY (`customer_id`) REFERENCES `customers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `customer_legal` ADD CONSTRAINT `customer_legal_complex_id_fkey` FOREIGN KEY (`complex_id`) REFERENCES `complexes`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `goods` ADD CONSTRAINT `goods_measure_unit_id_fkey` FOREIGN KEY (`measure_unit_id`) REFERENCES `measure_units`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `goods` ADD CONSTRAINT `goods_category_id_fkey` FOREIGN KEY (`category_id`) REFERENCES `good_categories`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `goods` ADD CONSTRAINT `goods_complex_id_fkey` FOREIGN KEY (`complex_id`) REFERENCES `complexes`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
ALTER TABLE `goods` ADD CONSTRAINT `goods_business_activity_id_fkey` FOREIGN KEY (`business_activity_id`) REFERENCES `business_activities`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `good_categories` ADD CONSTRAINT `good_categories_guild_id_fkey` FOREIGN KEY (`guild_id`) REFERENCES `guilds`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -546,14 +819,26 @@ ALTER TABLE `good_categories` ADD CONSTRAINT `good_categories_guild_id_fkey` FOR
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `good_categories` ADD CONSTRAINT `good_categories_complex_id_fkey` FOREIGN KEY (`complex_id`) REFERENCES `complexes`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `customer_individuals` ADD CONSTRAINT `customer_individuals_customer_id_fkey` FOREIGN KEY (`customer_id`) REFERENCES `customers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `customer_individuals` ADD CONSTRAINT `customer_individuals_business_activity_id_fkey` FOREIGN KEY (`business_activity_id`) REFERENCES `business_activities`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `customer_legal` ADD CONSTRAINT `customer_legal_customer_id_fkey` FOREIGN KEY (`customer_id`) REFERENCES `customers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `customer_legal` ADD CONSTRAINT `customer_legal_business_activity_id_fkey` FOREIGN KEY (`business_activity_id`) REFERENCES `business_activities`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `sales_invoices` ADD CONSTRAINT `sales_invoices_customer_id_fkey` FOREIGN KEY (`customer_id`) REFERENCES `customers`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `sales_invoices` ADD CONSTRAINT `sales_invoices_pos_id_fkey` FOREIGN KEY (`pos_id`) REFERENCES `poses`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `sales_invoices` ADD CONSTRAINT `sales_invoices_consumer_account_id_fkey` FOREIGN KEY (`consumer_account_id`) REFERENCES `consumer_accounts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `sales_invoices` ADD CONSTRAINT `sales_invoices_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `consumer_accounts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `sales_invoices` ADD CONSTRAINT `sales_invoices_pos_id_fkey` FOREIGN KEY (`pos_id`) REFERENCES `poses`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `sales_invoice_items` ADD CONSTRAINT `sales_invoice_items_invoice_id_fkey` FOREIGN KEY (`invoice_id`) REFERENCES `sales_invoices`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@@ -564,8 +849,17 @@ ALTER TABLE `sales_invoice_items` ADD CONSTRAINT `sales_invoice_items_good_id_fk
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `sales_invoice_items` ADD CONSTRAINT `sales_invoice_items_service_id_fkey` FOREIGN KEY (`service_id`) REFERENCES `services`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `sale_invoice_fiscals` ADD CONSTRAINT `sale_invoice_fiscals_invoice_id_fkey` FOREIGN KEY (`invoice_id`) REFERENCES `sales_invoices`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `sale_invoice_fiscal_attempts` ADD CONSTRAINT `sale_invoice_fiscal_attempts_fiscal_id_fkey` FOREIGN KEY (`fiscal_id`) REFERENCES `sale_invoice_fiscals`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `sales_invoice_payments` ADD CONSTRAINT `sales_invoice_payments_invoice_id_fkey` FOREIGN KEY (`invoice_id`) REFERENCES `sales_invoices`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `sales_invoice_payment_terminal_info` ADD CONSTRAINT `sales_invoice_payment_terminal_info_payment_id_fkey` FOREIGN KEY (`payment_id`) REFERENCES `sales_invoice_payments`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `services` ADD CONSTRAINT `services_category_id_fkey` FOREIGN KEY (`category_id`) REFERENCES `service_categories`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -8,7 +8,7 @@ model AdminAccount {
|
||||
admin Admin @relation(fields: [admin_id], references: [id])
|
||||
|
||||
account_id String @unique
|
||||
account Account @relation(fields: [account_id], references: [id])
|
||||
account Account @relation(fields: [account_id], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("admin_accounts")
|
||||
}
|
||||
|
||||
@@ -10,6 +10,18 @@ model Account {
|
||||
partner_account PartnerAccount?
|
||||
consumer_account ConsumerAccount?
|
||||
|
||||
// admin_account_id String? @unique
|
||||
// admin_account AdminAccount? @relation(fields: [admin_account_id], references: [id], onDelete: Cascade)
|
||||
|
||||
// provider_account_id String? @unique
|
||||
// provider_account ProviderAccount? @relation(fields: [provider_account_id], references: [id], onDelete: Cascade)
|
||||
|
||||
// partner_account_id String? @unique
|
||||
// partner_account PartnerAccount? @relation(fields: [partner_account_id], references: [id], onDelete: Cascade)
|
||||
|
||||
// consumer_account_id String? @unique
|
||||
// consumer_account ConsumerAccount? @relation(fields: [consumer_account_id], references: [id], onDelete: Cascade)
|
||||
|
||||
// tokens Token[]
|
||||
// refresh_tokens RefreshToken[]
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ model PartnerAccount {
|
||||
partner Partner @relation(fields: [partner_id], references: [id])
|
||||
|
||||
account_id String @unique
|
||||
account Account @relation(fields: [account_id], references: [id])
|
||||
account Account @relation(fields: [account_id], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("partner_accounts")
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ model ProviderAccount {
|
||||
provider Provider @relation(fields: [provider_id], references: [id])
|
||||
|
||||
account_id String @unique
|
||||
account Account @relation(fields: [account_id], references: [id])
|
||||
account Account @relation(fields: [account_id], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("provider_accounts")
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@ model Good {
|
||||
id String @id @default(ulid())
|
||||
name String @db.VarChar(255)
|
||||
is_default_guild_good Boolean @default(false)
|
||||
sku String @db.VarChar(100)
|
||||
unit_type UnitType
|
||||
pricing_model GoodPricingModel
|
||||
description String? @db.Text
|
||||
local_sku String? @unique() @db.VarChar(100)
|
||||
@@ -15,6 +13,12 @@ model Good {
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
deleted_at DateTime? @db.Timestamp(0)
|
||||
|
||||
sku_id String
|
||||
sku StockKeepingUnits @relation(fields: [sku_id], references: [id])
|
||||
|
||||
measure_unit_id String
|
||||
measure_unit MeasureUnits @relation(fields: [measure_unit_id], references: [id])
|
||||
|
||||
category_id String?
|
||||
category GoodCategory? @relation(fields: [category_id], references: [id])
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
model MeasureUnits {
|
||||
id String @id @default(ulid())
|
||||
code String @unique
|
||||
name String
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @default(now()) @updatedAt @db.Timestamp(0)
|
||||
|
||||
goods Good[]
|
||||
|
||||
@@map("measure_units")
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
model StockKeepingUnits {
|
||||
id String @id @default(ulid())
|
||||
code String @unique
|
||||
name String
|
||||
VAT Decimal @db.Decimal(5, 2)
|
||||
type SKUGuildType @default(GOLD)
|
||||
is_public Boolean @default(true)
|
||||
is_domestic Boolean @default(false)
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt() @db.Timestamp(0)
|
||||
|
||||
goods Good[]
|
||||
|
||||
@@index([code])
|
||||
@@map("stock_keeping_units")
|
||||
}
|
||||
@@ -36,7 +36,7 @@ model CustomerIndividual {
|
||||
}
|
||||
|
||||
model CustomerLegal {
|
||||
company_name String @db.VarChar(255)
|
||||
name String @db.VarChar(255)
|
||||
economic_code String @db.Char(10)
|
||||
registration_number String? @db.Char(20)
|
||||
postal_code String @db.Char(10)
|
||||
|
||||
@@ -165,4 +165,21 @@ enum FiscalResponseStatus {
|
||||
SUCCESS
|
||||
FAILURE
|
||||
NOT_SEND
|
||||
QUEUED
|
||||
}
|
||||
|
||||
enum FiscalRequestType {
|
||||
MAIN
|
||||
UPDATE
|
||||
REVOKE
|
||||
REMOVE
|
||||
}
|
||||
|
||||
enum FiscalInvoiceCustomerType {
|
||||
Unknown
|
||||
Known
|
||||
}
|
||||
|
||||
enum SKUGuildType {
|
||||
GOLD
|
||||
}
|
||||
|
||||
@@ -30,14 +30,17 @@ model SalesInvoice {
|
||||
}
|
||||
|
||||
model SalesInvoiceItem {
|
||||
id String @id @default(ulid())
|
||||
quantity Decimal @db.Decimal(10, 0)
|
||||
unit_type UnitType
|
||||
unit_price Decimal @default(0.00) @db.Decimal(15, 2)
|
||||
total_amount Decimal @default(0.00) @db.Decimal(15, 2)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
discount Decimal @default(0.00) @db.Decimal(15, 2)
|
||||
notes String? @db.Text
|
||||
id String @id @default(ulid())
|
||||
quantity Decimal @db.Decimal(10, 0)
|
||||
measure_unit_text String @db.VarChar(50)
|
||||
measure_unit_code String @db.VarChar(50)
|
||||
sku_code String @db.VarChar(50)
|
||||
sku_vat Decimal @default(0.00) @db.Decimal(15, 2)
|
||||
unit_price Decimal @default(0.00) @db.Decimal(15, 2)
|
||||
total_amount Decimal @default(0.00) @db.Decimal(15, 2)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
discount Decimal @default(0.00) @db.Decimal(15, 2)
|
||||
notes String? @db.Text
|
||||
|
||||
payload Json?
|
||||
good_snapshot Json?
|
||||
@@ -76,8 +79,9 @@ model SaleInvoiceFiscalAttempts {
|
||||
id String @id @default(ulid())
|
||||
|
||||
attempt_no Int
|
||||
status String @db.VarChar(50)
|
||||
tax_id String? @unique @db.VarChar(191)
|
||||
status FiscalResponseStatus
|
||||
tax_id String? @unique @db.VarChar(191)
|
||||
type FiscalRequestType
|
||||
|
||||
request_payload Json?
|
||||
response_payload Json?
|
||||
|
||||
+557
-406
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user