From 7553badfeb183eecc93cc92b17c814bd3a90b762 Mon Sep 17 00:00:00 2001 From: shafi54 <108669266+shafi-aviz@users.noreply.github.com> Date: Wed, 29 Jul 2026 20:56:16 +0530 Subject: [PATCH] db level --- apps/backend/wrangler.dev.toml | 6 +- .../drizzle/0002_sku_split.sql | 229 ++ .../drizzle/meta/0001_snapshot.json | 3422 ++++++++++++++++ .../drizzle/meta/0002_snapshot.json | 3513 +++++++++++++++++ .../drizzle/meta/_journal.json | 14 + packages/db_helper_sqlite/src/db/schema.ts | 75 +- packages/db_helper_sqlite/src/db/types.ts | 14 +- 7 files changed, 7240 insertions(+), 33 deletions(-) create mode 100644 packages/db_helper_sqlite/drizzle/0002_sku_split.sql create mode 100644 packages/db_helper_sqlite/drizzle/meta/0001_snapshot.json create mode 100644 packages/db_helper_sqlite/drizzle/meta/0002_snapshot.json diff --git a/apps/backend/wrangler.dev.toml b/apps/backend/wrangler.dev.toml index b05b479..99b12c3 100644 --- a/apps/backend/wrangler.dev.toml +++ b/apps/backend/wrangler.dev.toml @@ -8,8 +8,10 @@ routes = [ [[d1_databases]] binding = "DB" -database_name = "freshyo-backend-dev" -database_id = "6b93ddc9-9b24-4cfc-9320-e81aec38887a" +#database_name = "freshyo-backend-dev" +#database_id = "6b93ddc9-9b24-4cfc-9320-e81aec38887a" +database_name = "freshyo-dev" +database_id = "3cad440f-dc14-4baa-ab05-04eb08e206de" migrations_dir="../../packages/db_helper_sqlite/drizzle" migrations_pattern="migration.sql" [durable_objects] diff --git a/packages/db_helper_sqlite/drizzle/0002_sku_split.sql b/packages/db_helper_sqlite/drizzle/0002_sku_split.sql new file mode 100644 index 0000000..fcc01de --- /dev/null +++ b/packages/db_helper_sqlite/drizzle/0002_sku_split.sql @@ -0,0 +1,229 @@ +-- Migration: split product_info into product_info (catalog) + product_skus + sku_features +-- and move all buyable references from product ids to sku ids. + +-- PRAGMA foreign_keys=OFF; +PRAGMA defer_foreign_keys = on; + +-- 1. Create new SKU tables. +CREATE TABLE `product_skus` ( + `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, + `product_id` integer NOT NULL, + `name` text, + `price` text NOT NULL, + `market_price` text, + `images` text, + `is_out_of_stock` integer DEFAULT false NOT NULL, + `is_suspended` integer DEFAULT false NOT NULL, + `is_flash_available` integer DEFAULT false NOT NULL, + `flash_price` text, + `created_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + FOREIGN KEY (`product_id`) REFERENCES `product_info`(`id`) ON UPDATE no action ON DELETE no action +); + +CREATE TABLE `sku_features` ( + `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, + `sku_id` integer NOT NULL, + `feature_name` text NOT NULL, + `feature_value` text NOT NULL, + FOREIGN KEY (`sku_id`) REFERENCES `product_skus`(`id`) ON UPDATE no action ON DELETE no action +); + +CREATE UNIQUE INDEX `unique_sku_feature_name` ON `sku_features` (`sku_id`,`feature_name`); + +-- 2. Migrate each existing product into one default SKU plus a mandatory quantity feature. +INSERT INTO `product_skus` ( + `product_id`, `name`, `price`, `market_price`, `images`, `is_out_of_stock`, + `is_suspended`, `is_flash_available`, `flash_price`, `created_at` +) +SELECT + `id`, + NULL, + `price`, + `market_price`, + `images`, + `is_out_of_stock`, + `is_suspended`, + `is_flash_available`, + `flash_price`, + `created_at` +FROM `product_info`; + +INSERT INTO `sku_features` (`sku_id`, `feature_name`, `feature_value`) +SELECT + `ps`.`id`, + 'quantity', + CASE + WHEN CAST(`pi`.`product_quantity` AS INTEGER) = `pi`.`product_quantity` + THEN CAST(CAST(`pi`.`product_quantity` AS INTEGER) AS TEXT) + ELSE CAST(`pi`.`product_quantity` AS TEXT) + END || COALESCE(`u`.`short_notation`, '') +FROM `product_info` `pi` +JOIN `product_skus` `ps` ON `ps`.`product_id` = `pi`.`id` +LEFT JOIN `units` `u` ON `u`.`id` = `pi`.`unit_id`; + +-- 3. Build a product_id -> sku_id mapping for downstream tables. +CREATE TABLE `__product_to_sku` ( + `product_id` integer PRIMARY KEY, + `sku_id` integer NOT NULL +); + +INSERT INTO `__product_to_sku` (`product_id`, `sku_id`) +SELECT `product_id`, `id` FROM `product_skus`; + +-- 4. Recreate product_info with only catalog-level fields. +CREATE TABLE `__new_product_info` ( + `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, + `name` text NOT NULL, + `short_description` text, + `long_description` text, + `store_id` integer, + `increment_step` real DEFAULT 1 NOT NULL, + `created_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + FOREIGN KEY (`store_id`) REFERENCES `store_info`(`id`) ON UPDATE no action ON DELETE no action +); + +INSERT INTO `__new_product_info` ( + `id`, `name`, `short_description`, `long_description`, `store_id`, `increment_step`, `created_at` +) +SELECT + `id`, `name`, `short_description`, `long_description`, `store_id`, `increment_step`, `created_at` +FROM `product_info`; + +DROP TABLE `product_info`; +ALTER TABLE `__new_product_info` RENAME TO `product_info`; + +-- 5. Recreate tables that previously referenced product_info.id so they now reference product_skus.id. +CREATE TABLE `__new_cart_items` ( + `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, + `user_id` integer NOT NULL, + `sku_id` integer NOT NULL, + `quantity` text NOT NULL, + `added_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action, + FOREIGN KEY (`sku_id`) REFERENCES `product_skus`(`id`) ON UPDATE no action ON DELETE no action +); + +INSERT INTO `__new_cart_items` (`id`, `user_id`, `sku_id`, `quantity`, `added_at`) +SELECT + `ci`.`id`, `ci`.`user_id`, `m`.`sku_id`, `ci`.`quantity`, `ci`.`added_at` +FROM `cart_items` `ci` +JOIN `__product_to_sku` `m` ON `m`.`product_id` = `ci`.`product_id`; + +DROP TABLE `cart_items`; +ALTER TABLE `__new_cart_items` RENAME TO `cart_items`; +CREATE UNIQUE INDEX `unique_user_sku` ON `cart_items` (`user_id`,`sku_id`); + +CREATE TABLE `__new_order_items` ( + `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, + `order_id` integer NOT NULL, + `sku_id` integer NOT NULL, + `quantity` text NOT NULL, + `price` text NOT NULL, + `discounted_price` text, + `is_packaged` integer DEFAULT false NOT NULL, + `is_package_verified` integer DEFAULT false NOT NULL, + FOREIGN KEY (`order_id`) REFERENCES `orders`(`id`) ON UPDATE no action ON DELETE no action, + FOREIGN KEY (`sku_id`) REFERENCES `product_skus`(`id`) ON UPDATE no action ON DELETE no action +); + +INSERT INTO `__new_order_items` ( + `id`, `order_id`, `sku_id`, `quantity`, `price`, `discounted_price`, `is_packaged`, `is_package_verified` +) +SELECT + `oi`.`id`, `oi`.`order_id`, `m`.`sku_id`, `oi`.`quantity`, `oi`.`price`, + `oi`.`discounted_price`, `oi`.`is_packaged`, `oi`.`is_package_verified` +FROM `order_items` `oi` +JOIN `__product_to_sku` `m` ON `m`.`product_id` = `oi`.`product_id`; + +DROP TABLE `order_items`; +ALTER TABLE `__new_order_items` RENAME TO `order_items`; + +CREATE TABLE `__new_special_deals` ( + `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, + `sku_id` integer NOT NULL, + `quantity` text NOT NULL, + `price` text NOT NULL, + `valid_till` text NOT NULL, + FOREIGN KEY (`sku_id`) REFERENCES `product_skus`(`id`) ON UPDATE no action ON DELETE no action +); + +INSERT INTO `__new_special_deals` (`id`, `sku_id`, `quantity`, `price`, `valid_till`) +SELECT + `sd`.`id`, `m`.`sku_id`, `sd`.`quantity`, `sd`.`price`, `sd`.`valid_till` +FROM `special_deals` `sd` +JOIN `__product_to_sku` `m` ON `m`.`product_id` = `sd`.`product_id`; + +DROP TABLE `special_deals`; +ALTER TABLE `__new_special_deals` RENAME TO `special_deals`; + +CREATE TABLE `__new_coupon_applicable_products` ( + `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, + `coupon_id` integer NOT NULL, + `sku_id` integer NOT NULL, + FOREIGN KEY (`coupon_id`) REFERENCES `coupons`(`id`) ON UPDATE no action ON DELETE no action, + FOREIGN KEY (`sku_id`) REFERENCES `product_skus`(`id`) ON UPDATE no action ON DELETE no action +); + +INSERT INTO `__new_coupon_applicable_products` (`id`, `coupon_id`, `sku_id`) +SELECT + `cap`.`id`, `cap`.`coupon_id`, `m`.`sku_id` +FROM `coupon_applicable_products` `cap` +JOIN `__product_to_sku` `m` ON `m`.`product_id` = `cap`.`product_id`; + +DROP TABLE `coupon_applicable_products`; +ALTER TABLE `__new_coupon_applicable_products` RENAME TO `coupon_applicable_products`; +CREATE UNIQUE INDEX `unique_coupon_sku` ON `coupon_applicable_products` (`coupon_id`,`sku_id`); + +-- 6. Remap JSON product id arrays to sku id arrays (before renaming the columns). +UPDATE `delivery_slot_info` AS `target` +SET `product_ids` = COALESCE( + (SELECT json_group_array(`m`.`sku_id`) + FROM json_each(`target`.`product_ids`) AS `je` + JOIN `__product_to_sku` `m` ON `m`.`product_id` = `je`.`value`), + CASE WHEN `target`.`product_ids` IS NULL THEN NULL ELSE '[]' END +); + +UPDATE `home_banners` AS `target` +SET `product_ids` = COALESCE( + (SELECT json_group_array(`m`.`sku_id`) + FROM json_each(`target`.`product_ids`) AS `je` + JOIN `__product_to_sku` `m` ON `m`.`product_id` = `je`.`value`), + CASE WHEN `target`.`product_ids` IS NULL THEN NULL ELSE '[]' END +); + +UPDATE `coupons` AS `target` +SET `product_ids` = COALESCE( + (SELECT json_group_array(`m`.`sku_id`) + FROM json_each(`target`.`product_ids`) AS `je` + JOIN `__product_to_sku` `m` ON `m`.`product_id` = `je`.`value`), + CASE WHEN `target`.`product_ids` IS NULL THEN NULL ELSE '[]' END +); + +UPDATE `reserved_coupons` AS `target` +SET `product_ids` = COALESCE( + (SELECT json_group_array(`m`.`sku_id`) + FROM json_each(`target`.`product_ids`) AS `je` + JOIN `__product_to_sku` `m` ON `m`.`product_id` = `je`.`value`), + CASE WHEN `target`.`product_ids` IS NULL THEN NULL ELSE '[]' END +); + +UPDATE `vendor_snippets` AS `target` +SET `product_ids` = COALESCE( + (SELECT json_group_array(`m`.`sku_id`) + FROM json_each(`target`.`product_ids`) AS `je` + JOIN `__product_to_sku` `m` ON `m`.`product_id` = `je`.`value`), + '[]' +); + +-- 7. Rename JSON columns from product_ids to sku_ids. +ALTER TABLE `delivery_slot_info` RENAME COLUMN `product_ids` TO `sku_ids`; +ALTER TABLE `home_banners` RENAME COLUMN `product_ids` TO `sku_ids`; +ALTER TABLE `coupons` RENAME COLUMN `product_ids` TO `sku_ids`; +ALTER TABLE `reserved_coupons` RENAME COLUMN `product_ids` TO `sku_ids`; +ALTER TABLE `vendor_snippets` RENAME COLUMN `product_ids` TO `sku_ids`; + +-- 8. Clean up helper table. +DROP TABLE `__product_to_sku`; + +-- PRAGMA foreign_keys=ON; +PRAGMA defer_foreign_keys = off; diff --git a/packages/db_helper_sqlite/drizzle/meta/0001_snapshot.json b/packages/db_helper_sqlite/drizzle/meta/0001_snapshot.json new file mode 100644 index 0000000..ab1a2e6 --- /dev/null +++ b/packages/db_helper_sqlite/drizzle/meta/0001_snapshot.json @@ -0,0 +1,3422 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "6333861e-b629-4b55-9c0d-479fb080070b", + "prevId": "8b667990-7cbb-4115-89ee-b28da799ca9d", + "tables": { + "address_areas": { + "name": "address_areas", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "place_name": { + "name": "place_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "address_areas_zone_id_address_zones_id_fk": { + "name": "address_areas_zone_id_address_zones_id_fk", + "tableFrom": "address_areas", + "tableTo": "address_zones", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "address_zones": { + "name": "address_zones", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "zone_name": { + "name": "zone_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "added_at": { + "name": "added_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "addresses": { + "name": "addresses", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "address_line1": { + "name": "address_line1", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "address_line2": { + "name": "address_line2", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "city": { + "name": "city", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "pincode": { + "name": "pincode", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "is_default": { + "name": "is_default", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "google_maps_url": { + "name": "google_maps_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "admin_latitude": { + "name": "admin_latitude", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "admin_longitude": { + "name": "admin_longitude", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "addresses_zone_id_address_zones_id_fk": { + "name": "addresses_zone_id_address_zones_id_fk", + "tableFrom": "addresses", + "tableTo": "address_zones", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "cart_items": { + "name": "cart_items", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "quantity": { + "name": "quantity", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "added_at": { + "name": "added_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "unique_user_product": { + "name": "unique_user_product", + "columns": [ + "user_id", + "product_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "complaints": { + "name": "complaints", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "images": { + "name": "images", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "response": { + "name": "response", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "coupon_applicable_products": { + "name": "coupon_applicable_products", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "columns": [ + "coupon_id", + "product_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "coupon_applicable_users": { + "name": "coupon_applicable_users", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "columns": [ + "coupon_id", + "user_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "coupon_usage": { + "name": "coupon_usage", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "used_at": { + "name": "used_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "coupons": { + "name": "coupons", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "coupon_code": { + "name": "coupon_code", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "is_user_based": { + "name": "is_user_based", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "min_order": { + "name": "min_order", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "product_ids": { + "name": "product_ids", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "max_value": { + "name": "max_value", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "coupons_coupon_code_unique": { + "name": "coupons_coupon_code_unique", + "columns": [ + "coupon_code" + ], + "isUnique": true + } + }, + "foreignKeys": { + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "delivery_slot_info": { + "name": "delivery_slot_info", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "delivery_time": { + "name": "delivery_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "freeze_time": { + "name": "freeze_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "is_active": { + "name": "is_active", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "is_flash": { + "name": "is_flash", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "is_capacity_full": { + "name": "is_capacity_full", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "group_ids": { + "name": "group_ids", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "product_ids": { + "name": "product_ids", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "home_banners": { + "name": "home_banners", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "image_url": { + "name": "image_url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "product_ids": { + "name": "product_ids", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "redirect_url": { + "name": "redirect_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "serial_num": { + "name": "serial_num", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_active": { + "name": "is_active", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "last_updated": { + "name": "last_updated", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "key_val_store": { + "name": "key_val_store", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "notif_creds": { + "name": "notif_creds", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "added_at": { + "name": "added_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "last_verified": { + "name": "last_verified", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "columns": [ + "token" + ], + "isUnique": true + } + }, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "notifications": { + "name": "notifications", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_read": { + "name": "is_read", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "order_items": { + "name": "order_items", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "quantity": { + "name": "quantity", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "price": { + "name": "price", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "discounted_price": { + "name": "discounted_price", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_packaged": { + "name": "is_packaged", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "is_package_verified": { + "name": "is_package_verified", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "order_status": { + "name": "order_status", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "order_time": { + "name": "order_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "is_packaged": { + "name": "is_packaged", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_cancelled_by_admin": { + "name": "is_cancelled_by_admin", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_state": { + "name": "payment_state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "orders": { + "name": "orders", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_cod": { + "name": "is_cod", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "total_amount": { + "name": "total_amount", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "delivery_charge": { + "name": "delivery_charge", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'0'" + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "order_group_id": { + "name": "order_group_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "order_group_proportion": { + "name": "order_group_proportion", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_flash_delivery": { + "name": "is_flash_delivery", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "payment_info": { + "name": "payment_info", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "gateway": { + "name": "gateway", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "order_id": { + "name": "order_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "payload": { + "name": "payload", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "columns": [ + "merchant_order_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "payments": { + "name": "payments", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "gateway": { + "name": "gateway", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "payload": { + "name": "payload", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "columns": [ + "merchant_order_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "product_categories": { + "name": "product_categories", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "product_group_info": { + "name": "product_group_info", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "group_name": { + "name": "group_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "product_group_membership": { + "name": "product_group_membership", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "group_id": { + "name": "group_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "added_at": { + "name": "added_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "product_group_membership_product_id_product_info_id_fk": { + "name": "product_group_membership_product_id_product_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_info", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_group_membership_group_id_product_group_info_id_fk": { + "name": "product_group_membership_group_id_product_group_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_group_info", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "product_group_membership_pk": { + "columns": [ + "product_id", + "group_id" + ], + "name": "product_group_membership_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "product_info": { + "name": "product_info", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "short_description": { + "name": "short_description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "long_description": { + "name": "long_description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "price": { + "name": "price", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "market_price": { + "name": "market_price", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "images": { + "name": "images", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "is_flash_available": { + "name": "is_flash_available", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "flash_price": { + "name": "flash_price", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "increment_step": { + "name": "increment_step", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 1 + }, + "product_quantity": { + "name": "product_quantity", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 1 + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "product_reviews": { + "name": "product_reviews", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "review_body": { + "name": "review_body", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "image_urls": { + "name": "image_urls", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "review_time": { + "name": "review_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "ratings": { + "name": "ratings", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "admin_response": { + "name": "admin_response", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "admin_response_images": { + "name": "admin_response_images", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_reviews_user_id_users_id_fk": { + "name": "product_reviews_user_id_users_id_fk", + "tableFrom": "product_reviews", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_reviews_product_id_product_info_id_fk": { + "name": "product_reviews_product_id_product_info_id_fk", + "tableFrom": "product_reviews", + "tableTo": "product_info", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "rating_check": { + "name": "rating_check", + "value": "\"product_reviews\".\"ratings\" >= 1 AND \"product_reviews\".\"ratings\" <= 5" + } + } + }, + "product_tag_info": { + "name": "product_tag_info", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "tag_name": { + "name": "tag_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tag_description": { + "name": "tag_description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "image_url": { + "name": "image_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "related_stores": { + "name": "related_stores", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "columns": [ + "tag_name" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "product_tags": { + "name": "product_tags", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "assigned_at": { + "name": "assigned_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "unique_product_tag": { + "name": "unique_product_tag", + "columns": [ + "product_id", + "tag_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "refunds": { + "name": "refunds", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "refund_amount": { + "name": "refund_amount", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refund_status": { + "name": "refund_status", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "reserved_coupons": { + "name": "reserved_coupons", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "secret_code": { + "name": "secret_code", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "coupon_code": { + "name": "coupon_code", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "min_order": { + "name": "min_order", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "product_ids": { + "name": "product_ids", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "max_value": { + "name": "max_value", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "valid_till": { + "name": "valid_till", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "is_redeemed": { + "name": "is_redeemed", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "redeemed_by": { + "name": "redeemed_by", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "redeemed_at": { + "name": "redeemed_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "reserved_coupons_secret_code_unique": { + "name": "reserved_coupons_secret_code_unique", + "columns": [ + "secret_code" + ], + "isUnique": true + } + }, + "foreignKeys": { + "reserved_coupons_redeemed_by_users_id_fk": { + "name": "reserved_coupons_redeemed_by_users_id_fk", + "tableFrom": "reserved_coupons", + "tableTo": "users", + "columnsFrom": [ + "redeemed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reserved_coupons_created_by_staff_users_id_fk": { + "name": "reserved_coupons_created_by_staff_users_id_fk", + "tableFrom": "reserved_coupons", + "tableTo": "staff_users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "special_deals": { + "name": "special_deals", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "quantity": { + "name": "quantity", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "price": { + "name": "price", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "valid_till": { + "name": "valid_till", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "staff_permissions": { + "name": "staff_permissions", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "permission_name": { + "name": "permission_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "unique_permission_name": { + "name": "unique_permission_name", + "columns": [ + "permission_name" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "staff_role_permissions": { + "name": "staff_role_permissions", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "staff_role_id": { + "name": "staff_role_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "staff_permission_id": { + "name": "staff_permission_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "unique_role_permission": { + "name": "unique_role_permission", + "columns": [ + "staff_role_id", + "staff_permission_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "staff_role_permissions_staff_role_id_staff_roles_id_fk": { + "name": "staff_role_permissions_staff_role_id_staff_roles_id_fk", + "tableFrom": "staff_role_permissions", + "tableTo": "staff_roles", + "columnsFrom": [ + "staff_role_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "staff_role_permissions_staff_permission_id_staff_permissions_id_fk": { + "name": "staff_role_permissions_staff_permission_id_staff_permissions_id_fk", + "tableFrom": "staff_role_permissions", + "tableTo": "staff_permissions", + "columnsFrom": [ + "staff_permission_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "staff_roles": { + "name": "staff_roles", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "role_name": { + "name": "role_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "unique_role_name": { + "name": "unique_role_name", + "columns": [ + "role_name" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "staff_users": { + "name": "staff_users", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "staff_role_id": { + "name": "staff_role_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "staff_users_staff_role_id_staff_roles_id_fk": { + "name": "staff_users_staff_role_id_staff_roles_id_fk", + "tableFrom": "staff_users", + "tableTo": "staff_roles", + "columnsFrom": [ + "staff_role_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "store_info": { + "name": "store_info", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "image_url": { + "name": "image_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "units": { + "name": "units", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "short_notation": { + "name": "short_notation", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "full_name": { + "name": "full_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "unique_short_notation": { + "name": "unique_short_notation", + "columns": [ + "short_notation" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "unlogged_user_tokens": { + "name": "unlogged_user_tokens", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "added_at": { + "name": "added_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "last_verified": { + "name": "last_verified", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "unlogged_user_tokens_token_unique": { + "name": "unlogged_user_tokens_token_unique", + "columns": [ + "token" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "upload_url_status": { + "name": "upload_url_status", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "user_creds": { + "name": "user_creds", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_password": { + "name": "user_password", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "user_details": { + "name": "user_details", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "bio": { + "name": "bio", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "gender": { + "name": "gender", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "occupation": { + "name": "occupation", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "profile_image": { + "name": "profile_image", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "columns": [ + "user_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "user_incidents": { + "name": "user_incidents", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "date_added": { + "name": "date_added", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "admin_comment": { + "name": "admin_comment", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "added_by": { + "name": "added_by", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "negativity_score": { + "name": "negativity_score", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "user_incidents_user_id_users_id_fk": { + "name": "user_incidents_user_id_users_id_fk", + "tableFrom": "user_incidents", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "user_incidents_order_id_orders_id_fk": { + "name": "user_incidents_order_id_orders_id_fk", + "tableFrom": "user_incidents", + "tableTo": "orders", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "user_incidents_added_by_staff_users_id_fk": { + "name": "user_incidents_added_by_staff_users_id_fk", + "tableFrom": "user_incidents", + "tableTo": "staff_users", + "columnsFrom": [ + "added_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "user_notifications": { + "name": "user_notifications", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "image_url": { + "name": "image_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "applicable_users": { + "name": "applicable_users", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "users": { + "name": "users", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "mobile": { + "name": "mobile", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "unique_email": { + "name": "unique_email", + "columns": [ + "email" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "vendor_snippets": { + "name": "vendor_snippets", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "snippet_code": { + "name": "snippet_code", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_permanent": { + "name": "is_permanent", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "product_ids": { + "name": "product_ids", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "valid_till": { + "name": "valid_till", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "columns": [ + "snippet_code" + ], + "isUnique": true + } + }, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/packages/db_helper_sqlite/drizzle/meta/0002_snapshot.json b/packages/db_helper_sqlite/drizzle/meta/0002_snapshot.json new file mode 100644 index 0000000..5983e40 --- /dev/null +++ b/packages/db_helper_sqlite/drizzle/meta/0002_snapshot.json @@ -0,0 +1,3513 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "f0d1afa9-2cca-4080-b870-2c49e0e37883", + "prevId": "6333861e-b629-4b55-9c0d-479fb080070b", + "tables": { + "address_areas": { + "name": "address_areas", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "place_name": { + "name": "place_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "address_areas_zone_id_address_zones_id_fk": { + "name": "address_areas_zone_id_address_zones_id_fk", + "tableFrom": "address_areas", + "tableTo": "address_zones", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "address_zones": { + "name": "address_zones", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "zone_name": { + "name": "zone_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "added_at": { + "name": "added_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "addresses": { + "name": "addresses", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "address_line1": { + "name": "address_line1", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "address_line2": { + "name": "address_line2", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "city": { + "name": "city", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "pincode": { + "name": "pincode", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "is_default": { + "name": "is_default", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "google_maps_url": { + "name": "google_maps_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "admin_latitude": { + "name": "admin_latitude", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "admin_longitude": { + "name": "admin_longitude", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "addresses_zone_id_address_zones_id_fk": { + "name": "addresses_zone_id_address_zones_id_fk", + "tableFrom": "addresses", + "tableTo": "address_zones", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "cart_items": { + "name": "cart_items", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sku_id": { + "name": "sku_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "quantity": { + "name": "quantity", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "added_at": { + "name": "added_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "unique_user_sku": { + "name": "unique_user_sku", + "columns": [ + "user_id", + "sku_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_sku_id_product_skus_id_fk": { + "name": "cart_items_sku_id_product_skus_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_skus", + "columnsFrom": [ + "sku_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "complaints": { + "name": "complaints", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "images": { + "name": "images", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "response": { + "name": "response", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "coupon_applicable_products": { + "name": "coupon_applicable_products", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sku_id": { + "name": "sku_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "unique_coupon_sku": { + "name": "unique_coupon_sku", + "columns": [ + "coupon_id", + "sku_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_sku_id_product_skus_id_fk": { + "name": "coupon_applicable_products_sku_id_product_skus_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_skus", + "columnsFrom": [ + "sku_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "coupon_applicable_users": { + "name": "coupon_applicable_users", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "columns": [ + "coupon_id", + "user_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "coupon_usage": { + "name": "coupon_usage", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "used_at": { + "name": "used_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "coupons": { + "name": "coupons", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "coupon_code": { + "name": "coupon_code", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "is_user_based": { + "name": "is_user_based", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "min_order": { + "name": "min_order", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "sku_ids": { + "name": "sku_ids", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "max_value": { + "name": "max_value", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "coupons_coupon_code_unique": { + "name": "coupons_coupon_code_unique", + "columns": [ + "coupon_code" + ], + "isUnique": true + } + }, + "foreignKeys": { + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "delivery_slot_info": { + "name": "delivery_slot_info", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "delivery_time": { + "name": "delivery_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "freeze_time": { + "name": "freeze_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "is_active": { + "name": "is_active", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "is_flash": { + "name": "is_flash", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "is_capacity_full": { + "name": "is_capacity_full", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "group_ids": { + "name": "group_ids", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "sku_ids": { + "name": "sku_ids", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "home_banners": { + "name": "home_banners", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "image_url": { + "name": "image_url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "sku_ids": { + "name": "sku_ids", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "redirect_url": { + "name": "redirect_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "serial_num": { + "name": "serial_num", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_active": { + "name": "is_active", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "last_updated": { + "name": "last_updated", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "key_val_store": { + "name": "key_val_store", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "notif_creds": { + "name": "notif_creds", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "added_at": { + "name": "added_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "last_verified": { + "name": "last_verified", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "columns": [ + "token" + ], + "isUnique": true + } + }, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "notifications": { + "name": "notifications", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_read": { + "name": "is_read", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "order_items": { + "name": "order_items", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sku_id": { + "name": "sku_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "quantity": { + "name": "quantity", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "price": { + "name": "price", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "discounted_price": { + "name": "discounted_price", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_packaged": { + "name": "is_packaged", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "is_package_verified": { + "name": "is_package_verified", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_sku_id_product_skus_id_fk": { + "name": "order_items_sku_id_product_skus_id_fk", + "tableFrom": "order_items", + "tableTo": "product_skus", + "columnsFrom": [ + "sku_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "order_status": { + "name": "order_status", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "order_time": { + "name": "order_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "is_packaged": { + "name": "is_packaged", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_cancelled_by_admin": { + "name": "is_cancelled_by_admin", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_state": { + "name": "payment_state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "orders": { + "name": "orders", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_cod": { + "name": "is_cod", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "total_amount": { + "name": "total_amount", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "delivery_charge": { + "name": "delivery_charge", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'0'" + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "order_group_id": { + "name": "order_group_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "order_group_proportion": { + "name": "order_group_proportion", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_flash_delivery": { + "name": "is_flash_delivery", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "payment_info": { + "name": "payment_info", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "gateway": { + "name": "gateway", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "order_id": { + "name": "order_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "payload": { + "name": "payload", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "columns": [ + "merchant_order_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "payments": { + "name": "payments", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "gateway": { + "name": "gateway", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "payload": { + "name": "payload", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "columns": [ + "merchant_order_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "product_categories": { + "name": "product_categories", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "product_group_info": { + "name": "product_group_info", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "group_name": { + "name": "group_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "product_group_membership": { + "name": "product_group_membership", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "group_id": { + "name": "group_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "added_at": { + "name": "added_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "product_group_membership_product_id_product_info_id_fk": { + "name": "product_group_membership_product_id_product_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_info", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_group_membership_group_id_product_group_info_id_fk": { + "name": "product_group_membership_group_id_product_group_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_group_info", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "product_group_membership_pk": { + "columns": [ + "product_id", + "group_id" + ], + "name": "product_group_membership_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "product_info": { + "name": "product_info", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "short_description": { + "name": "short_description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "long_description": { + "name": "long_description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "increment_step": { + "name": "increment_step", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "product_reviews": { + "name": "product_reviews", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "review_body": { + "name": "review_body", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "image_urls": { + "name": "image_urls", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "review_time": { + "name": "review_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "ratings": { + "name": "ratings", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "admin_response": { + "name": "admin_response", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "admin_response_images": { + "name": "admin_response_images", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_reviews_user_id_users_id_fk": { + "name": "product_reviews_user_id_users_id_fk", + "tableFrom": "product_reviews", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_reviews_product_id_product_info_id_fk": { + "name": "product_reviews_product_id_product_info_id_fk", + "tableFrom": "product_reviews", + "tableTo": "product_info", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": { + "rating_check": { + "name": "rating_check", + "value": "\"product_reviews\".\"ratings\" >= 1 AND \"product_reviews\".\"ratings\" <= 5" + } + } + }, + "product_skus": { + "name": "product_skus", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "price": { + "name": "price", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "market_price": { + "name": "market_price", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "images": { + "name": "images", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "is_flash_available": { + "name": "is_flash_available", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "flash_price": { + "name": "flash_price", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "product_skus_product_id_product_info_id_fk": { + "name": "product_skus_product_id_product_info_id_fk", + "tableFrom": "product_skus", + "tableTo": "product_info", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "product_tag_info": { + "name": "product_tag_info", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "tag_name": { + "name": "tag_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tag_description": { + "name": "tag_description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "image_url": { + "name": "image_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "related_stores": { + "name": "related_stores", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "columns": [ + "tag_name" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "product_tags": { + "name": "product_tags", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "assigned_at": { + "name": "assigned_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "unique_product_tag": { + "name": "unique_product_tag", + "columns": [ + "product_id", + "tag_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "refunds": { + "name": "refunds", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "refund_amount": { + "name": "refund_amount", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refund_status": { + "name": "refund_status", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "reserved_coupons": { + "name": "reserved_coupons", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "secret_code": { + "name": "secret_code", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "coupon_code": { + "name": "coupon_code", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "min_order": { + "name": "min_order", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "sku_ids": { + "name": "sku_ids", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "max_value": { + "name": "max_value", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "valid_till": { + "name": "valid_till", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "is_redeemed": { + "name": "is_redeemed", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "redeemed_by": { + "name": "redeemed_by", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "redeemed_at": { + "name": "redeemed_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "reserved_coupons_secret_code_unique": { + "name": "reserved_coupons_secret_code_unique", + "columns": [ + "secret_code" + ], + "isUnique": true + } + }, + "foreignKeys": { + "reserved_coupons_redeemed_by_users_id_fk": { + "name": "reserved_coupons_redeemed_by_users_id_fk", + "tableFrom": "reserved_coupons", + "tableTo": "users", + "columnsFrom": [ + "redeemed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reserved_coupons_created_by_staff_users_id_fk": { + "name": "reserved_coupons_created_by_staff_users_id_fk", + "tableFrom": "reserved_coupons", + "tableTo": "staff_users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sku_features": { + "name": "sku_features", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "sku_id": { + "name": "sku_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "feature_name": { + "name": "feature_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "feature_value": { + "name": "feature_value", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "unique_sku_feature_name": { + "name": "unique_sku_feature_name", + "columns": [ + "sku_id", + "feature_name" + ], + "isUnique": true + } + }, + "foreignKeys": { + "sku_features_sku_id_product_skus_id_fk": { + "name": "sku_features_sku_id_product_skus_id_fk", + "tableFrom": "sku_features", + "tableTo": "product_skus", + "columnsFrom": [ + "sku_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "special_deals": { + "name": "special_deals", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "sku_id": { + "name": "sku_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "quantity": { + "name": "quantity", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "price": { + "name": "price", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "valid_till": { + "name": "valid_till", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_sku_id_product_skus_id_fk": { + "name": "special_deals_sku_id_product_skus_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_skus", + "columnsFrom": [ + "sku_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "staff_permissions": { + "name": "staff_permissions", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "permission_name": { + "name": "permission_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "unique_permission_name": { + "name": "unique_permission_name", + "columns": [ + "permission_name" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "staff_role_permissions": { + "name": "staff_role_permissions", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "staff_role_id": { + "name": "staff_role_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "staff_permission_id": { + "name": "staff_permission_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "unique_role_permission": { + "name": "unique_role_permission", + "columns": [ + "staff_role_id", + "staff_permission_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "staff_role_permissions_staff_role_id_staff_roles_id_fk": { + "name": "staff_role_permissions_staff_role_id_staff_roles_id_fk", + "tableFrom": "staff_role_permissions", + "tableTo": "staff_roles", + "columnsFrom": [ + "staff_role_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "staff_role_permissions_staff_permission_id_staff_permissions_id_fk": { + "name": "staff_role_permissions_staff_permission_id_staff_permissions_id_fk", + "tableFrom": "staff_role_permissions", + "tableTo": "staff_permissions", + "columnsFrom": [ + "staff_permission_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "staff_roles": { + "name": "staff_roles", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "role_name": { + "name": "role_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "unique_role_name": { + "name": "unique_role_name", + "columns": [ + "role_name" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "staff_users": { + "name": "staff_users", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "staff_role_id": { + "name": "staff_role_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "staff_users_staff_role_id_staff_roles_id_fk": { + "name": "staff_users_staff_role_id_staff_roles_id_fk", + "tableFrom": "staff_users", + "tableTo": "staff_roles", + "columnsFrom": [ + "staff_role_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "store_info": { + "name": "store_info", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "image_url": { + "name": "image_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "units": { + "name": "units", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "short_notation": { + "name": "short_notation", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "full_name": { + "name": "full_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "unique_short_notation": { + "name": "unique_short_notation", + "columns": [ + "short_notation" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "unlogged_user_tokens": { + "name": "unlogged_user_tokens", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "added_at": { + "name": "added_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "last_verified": { + "name": "last_verified", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "unlogged_user_tokens_token_unique": { + "name": "unlogged_user_tokens_token_unique", + "columns": [ + "token" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "upload_url_status": { + "name": "upload_url_status", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "user_creds": { + "name": "user_creds", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_password": { + "name": "user_password", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "user_details": { + "name": "user_details", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "bio": { + "name": "bio", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "gender": { + "name": "gender", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "occupation": { + "name": "occupation", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "profile_image": { + "name": "profile_image", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "columns": [ + "user_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "user_incidents": { + "name": "user_incidents", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "date_added": { + "name": "date_added", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "admin_comment": { + "name": "admin_comment", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "added_by": { + "name": "added_by", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "negativity_score": { + "name": "negativity_score", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "user_incidents_user_id_users_id_fk": { + "name": "user_incidents_user_id_users_id_fk", + "tableFrom": "user_incidents", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "user_incidents_order_id_orders_id_fk": { + "name": "user_incidents_order_id_orders_id_fk", + "tableFrom": "user_incidents", + "tableTo": "orders", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "user_incidents_added_by_staff_users_id_fk": { + "name": "user_incidents_added_by_staff_users_id_fk", + "tableFrom": "user_incidents", + "tableTo": "staff_users", + "columnsFrom": [ + "added_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "user_notifications": { + "name": "user_notifications", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "image_url": { + "name": "image_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "applicable_users": { + "name": "applicable_users", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "users": { + "name": "users", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "mobile": { + "name": "mobile", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "unique_email": { + "name": "unique_email", + "columns": [ + "email" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "vendor_snippets": { + "name": "vendor_snippets", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "snippet_code": { + "name": "snippet_code", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_permanent": { + "name": "is_permanent", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "sku_ids": { + "name": "sku_ids", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "valid_till": { + "name": "valid_till", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "columns": [ + "snippet_code" + ], + "isUnique": true + } + }, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": { + "\"cart_items\".\"product_id\"": "\"cart_items\".\"sku_id\"", + "\"delivery_slot_info\".\"product_ids\"": "\"delivery_slot_info\".\"sku_ids\"", + "\"home_banners\".\"product_ids\"": "\"home_banners\".\"sku_ids\"", + "\"order_items\".\"product_id\"": "\"order_items\".\"sku_id\"" + } + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/packages/db_helper_sqlite/drizzle/meta/_journal.json b/packages/db_helper_sqlite/drizzle/meta/_journal.json index b4636c1..f81f69f 100644 --- a/packages/db_helper_sqlite/drizzle/meta/_journal.json +++ b/packages/db_helper_sqlite/drizzle/meta/_journal.json @@ -8,6 +8,20 @@ "when": 1774588140474, "tag": "0000_nifty_sauron", "breakpoints": true + }, + { + "idx": 1, + "version": "6", + "when": 1785336112559, + "tag": "0001_migrate_product_slots", + "breakpoints": true + }, + { + "idx": 2, + "version": "6", + "when": 1785336600165, + "tag": "0002_sku_split", + "breakpoints": true } ] } \ No newline at end of file diff --git a/packages/db_helper_sqlite/src/db/schema.ts b/packages/db_helper_sqlite/src/db/schema.ts index 4985f39..14dfc7f 100644 --- a/packages/db_helper_sqlite/src/db/schema.ts +++ b/packages/db_helper_sqlite/src/db/schema.ts @@ -189,7 +189,15 @@ export const productInfo = sqliteTable('product_info', { name: text().notNull(), shortDescription: text('short_description'), longDescription: text('long_description'), - unitId: integer('unit_id').notNull().references(() => units.id), + storeId: integer('store_id').references(() => storeInfo.id), + incrementStep: real('increment_step').notNull().default(1), + createdAt: timestampText('created_at').notNull().default(sql`CURRENT_TIMESTAMP`), +}) + +export const productSkus = sqliteTable('product_skus', { + id: integer().primaryKey({ autoIncrement: true }), + productId: integer('product_id').notNull().references(() => productInfo.id), + name: text(), price: numericText('price').notNull(), marketPrice: numericText('market_price'), images: jsonText('images'), @@ -198,11 +206,17 @@ export const productInfo = sqliteTable('product_info', { isFlashAvailable: integer('is_flash_available', { mode: 'boolean' }).notNull().default(false), flashPrice: numericText('flash_price'), createdAt: timestampText('created_at').notNull().default(sql`CURRENT_TIMESTAMP`), - incrementStep: real('increment_step').notNull().default(1), - productQuantity: real('product_quantity').notNull().default(1), - storeId: integer('store_id').references(() => storeInfo.id), }) +export const skuFeatures = sqliteTable('sku_features', { + id: integer().primaryKey({ autoIncrement: true }), + skuId: integer('sku_id').notNull().references(() => productSkus.id), + featureName: text('feature_name').notNull(), + featureValue: text('feature_value').notNull(), +}, (t) => ({ + unq_sku_feature_name: uniqueIndex('unique_sku_feature_name').on(t.skuId, t.featureName), +})) + export const productGroupInfo = sqliteTable('product_group_info', { id: integer().primaryKey({ autoIncrement: true }), groupName: text('group_name').notNull(), @@ -223,7 +237,7 @@ export const homeBanners = sqliteTable('home_banners', { name: text('name').notNull(), imageUrl: text('image_url').notNull(), description: text('description'), - productIds: jsonText('product_ids'), + skuIds: jsonText('sku_ids'), redirectUrl: text('redirect_url'), serialNum: integer('serial_num'), isActive: integer('is_active', { mode: 'boolean' }).notNull().default(false), @@ -280,7 +294,7 @@ export const deliverySlotInfo = sqliteTable('delivery_slot_info', { isCapacityFull: integer('is_capacity_full', { mode: 'boolean' }).notNull().default(false), deliverySequence: jsonText>('delivery_sequence').$defaultFn(() => ({})), groupIds: jsonText('group_ids').$defaultFn(() => []), - productIds: jsonText('product_ids').$defaultFn(() => []), + skuIds: jsonText('sku_ids').$defaultFn(() => []), }) export const vendorSnippets = sqliteTable('vendor_snippets', { @@ -288,14 +302,14 @@ export const vendorSnippets = sqliteTable('vendor_snippets', { snippetCode: text('snippet_code').notNull().unique(), slotId: integer('slot_id').references(() => deliverySlotInfo.id), isPermanent: integer('is_permanent', { mode: 'boolean' }).notNull().default(false), - productIds: jsonText('product_ids').notNull(), + skuIds: jsonText('sku_ids').notNull(), validTill: timestampText('valid_till'), createdAt: timestampText('created_at').notNull().default(sql`CURRENT_TIMESTAMP`), }) export const specialDeals = sqliteTable('special_deals', { id: integer().primaryKey({ autoIncrement: true }), - productId: integer('product_id').notNull().references(() => productInfo.id), + skuId: integer('sku_id').notNull().references(() => productSkus.id), quantity: numericText('quantity').notNull(), price: numericText('price').notNull(), validTill: timestampText('valid_till').notNull(), @@ -333,7 +347,7 @@ export const orders = sqliteTable('orders', { export const orderItems = sqliteTable('order_items', { id: integer().primaryKey({ autoIncrement: true }), orderId: integer('order_id').notNull().references(() => orders.id), - productId: integer('product_id').notNull().references(() => productInfo.id), + skuId: integer('sku_id').notNull().references(() => productSkus.id), quantity: text('quantity').notNull(), price: numericText('price').notNull(), discountedPrice: numericText('discounted_price'), @@ -403,11 +417,11 @@ export const productCategories = sqliteTable('product_categories', { export const cartItems = sqliteTable('cart_items', { id: integer().primaryKey({ autoIncrement: true }), userId: integer('user_id').notNull().references(() => users.id), - productId: integer('product_id').notNull().references(() => productInfo.id), + skuId: integer('sku_id').notNull().references(() => productSkus.id), quantity: numericText('quantity').notNull(), addedAt: timestampText('added_at').notNull().default(sql`CURRENT_TIMESTAMP`), }, (t) => ({ - unq_user_product: uniqueIndex('unique_user_product').on(t.userId, t.productId), + unq_user_sku: uniqueIndex('unique_user_sku').on(t.userId, t.skuId), })) export const complaints = sqliteTable('complaints', { @@ -428,7 +442,7 @@ export const coupons = sqliteTable('coupons', { discountPercent: numericText('discount_percent'), flatDiscount: numericText('flat_discount'), minOrder: numericText('min_order'), - productIds: jsonText('product_ids'), + skuIds: jsonText('sku_ids'), createdBy: integer('created_by').notNull().references(() => staffUsers.id), maxValue: numericText('max_value'), isApplyForAll: integer('is_apply_for_all', { mode: 'boolean' }).notNull().default(false), @@ -459,9 +473,9 @@ export const couponApplicableUsers = sqliteTable('coupon_applicable_users', { export const couponApplicableProducts = sqliteTable('coupon_applicable_products', { id: integer().primaryKey({ autoIncrement: true }), couponId: integer('coupon_id').notNull().references(() => coupons.id), - productId: integer('product_id').notNull().references(() => productInfo.id), + skuId: integer('sku_id').notNull().references(() => productSkus.id), }, (t) => ({ - unq_coupon_product: uniqueIndex('unique_coupon_product').on(t.couponId, t.productId), + unq_coupon_sku: uniqueIndex('unique_coupon_sku').on(t.couponId, t.skuId), })) export const userIncidents = sqliteTable('user_incidents', { @@ -481,7 +495,7 @@ export const reservedCoupons = sqliteTable('reserved_coupons', { discountPercent: numericText('discount_percent'), flatDiscount: numericText('flat_discount'), minOrder: numericText('min_order'), - productIds: jsonText('product_ids'), + skuIds: jsonText('sku_ids'), maxValue: numericText('max_value'), validTill: timestampText('valid_till'), maxLimitForUser: integer('max_limit_for_user'), @@ -548,20 +562,29 @@ export const addressesRelations = relations(addresses, ({ one, many }) => ({ zone: one(addressZones, { fields: [addresses.zoneId], references: [addressZones.id] }), })) -export const unitsRelations = relations(units, ({ many }) => ({ - products: many(productInfo), +export const unitsRelations = relations(units, ({}) => ({ + // Units are no longer linked to products/SKUs; kept as a reference table. })) export const productInfoRelations = relations(productInfo, ({ one, many }) => ({ - unit: one(units, { fields: [productInfo.unitId], references: [units.id] }), store: one(storeInfo, { fields: [productInfo.storeId], references: [storeInfo.id] }), + skus: many(productSkus), + tags: many(productTags), + reviews: many(productReviews), + groups: many(productGroupMembership), +})) + +export const productSkusRelations = relations(productSkus, ({ one, many }) => ({ + product: one(productInfo, { fields: [productSkus.productId], references: [productInfo.id] }), + features: many(skuFeatures), specialDeals: many(specialDeals), orderItems: many(orderItems), cartItems: many(cartItems), - tags: many(productTags), applicableCoupons: many(couponApplicableProducts), - reviews: many(productReviews), - groups: many(productGroupMembership), +})) + +export const skuFeaturesRelations = relations(skuFeatures, ({ one }) => ({ + sku: one(productSkus, { fields: [skuFeatures.skuId], references: [productSkus.id] }), })) export const productTagInfoRelations = relations(productTagInfo, ({ many }) => ({ @@ -579,7 +602,7 @@ export const deliverySlotInfoRelations = relations(deliverySlotInfo, ({ many }) })) export const specialDealsRelations = relations(specialDeals, ({ one }) => ({ - product: one(productInfo, { fields: [specialDeals.productId], references: [productInfo.id] }), + sku: one(productSkus, { fields: [specialDeals.skuId], references: [productSkus.id] }), })) export const ordersRelations = relations(orders, ({ one, many }) => ({ @@ -597,7 +620,7 @@ export const ordersRelations = relations(orders, ({ one, many }) => ({ export const orderItemsRelations = relations(orderItems, ({ one }) => ({ order: one(orders, { fields: [orderItems.orderId], references: [orders.id] }), - product: one(productInfo, { fields: [orderItems.productId], references: [productInfo.id] }), + sku: one(productSkus, { fields: [orderItems.skuId], references: [productSkus.id] }), })) export const orderStatusRelations = relations(orderStatus, ({ one }) => ({ @@ -626,7 +649,7 @@ export const productCategoriesRelations = relations(productCategories, ({}) => ( export const cartItemsRelations = relations(cartItems, ({ one }) => ({ user: one(users, { fields: [cartItems.userId], references: [users.id] }), - product: one(productInfo, { fields: [cartItems.productId], references: [productInfo.id] }), + sku: one(productSkus, { fields: [cartItems.skuId], references: [productSkus.id] }), })) export const complaintsRelations = relations(complaints, ({ one }) => ({ @@ -672,7 +695,7 @@ export const couponApplicableUsersRelations = relations(couponApplicableUsers, ( export const couponApplicableProductsRelations = relations(couponApplicableProducts, ({ one }) => ({ coupon: one(coupons, { fields: [couponApplicableProducts.couponId], references: [coupons.id] }), - product: one(productInfo, { fields: [couponApplicableProducts.productId], references: [productInfo.id] }), + sku: one(productSkus, { fields: [couponApplicableProducts.skuId], references: [productSkus.id] }), })) export const reservedCouponsRelations = relations(reservedCoupons, ({ one }) => ({ @@ -704,7 +727,7 @@ export const productGroupMembershipRelations = relations(productGroupMembership, })) export const homeBannersRelations = relations(homeBanners, ({}) => ({ - // Relations for productIds array would be more complex, skipping for now + // Relations for skuIds array would be more complex, skipping for now })) export const staffRolesRelations = relations(staffRoles, ({ many }) => ({ diff --git a/packages/db_helper_sqlite/src/db/types.ts b/packages/db_helper_sqlite/src/db/types.ts index 5fb5214..84e2c17 100644 --- a/packages/db_helper_sqlite/src/db/types.ts +++ b/packages/db_helper_sqlite/src/db/types.ts @@ -4,6 +4,8 @@ import type { addresses, units, productInfo, + productSkus, + skuFeatures, deliverySlotInfo, specialDeals, orders, @@ -19,6 +21,8 @@ export type User = InferSelectModel export type Address = InferSelectModel export type Unit = InferSelectModel export type ProductInfo = InferSelectModel +export type ProductSku = InferSelectModel +export type SkuFeature = InferSelectModel export type DeliverySlotInfo = InferSelectModel export type SpecialDeal = InferSelectModel export type Order = InferSelectModel @@ -30,16 +34,16 @@ export type CartItem = InferSelectModel export type Coupon = InferSelectModel // Combined types -export type ProductWithUnit = ProductInfo & { - unit: Unit +export type ProductWithSkus = ProductInfo & { + skus: (ProductSku & { features: SkuFeature[] })[] } export type OrderWithItems = Order & { - items: (OrderItem & { product: ProductInfo })[] + items: (OrderItem & { sku: ProductSku & { product: ProductInfo } })[] address: Address slot: DeliverySlotInfo } -export type CartItemWithProduct = CartItem & { - product: ProductInfo +export type CartItemWithSku = CartItem & { + sku: ProductSku & { product: ProductInfo } }