/* Navicat Premium Data Transfer Source Server : InventoryProMax Source Server Type : SQLite Source Server Version : 3035005 Source Schema : main Target Server Type : SQLite Target Server Version : 3035005 File Encoding : 65001 Date: 15/04/2022 18:21:34 */ PRAGMA foreign_keys = false; -- ---------------------------- -- Table structure for r_inv_admin -- ---------------------------- DROP TABLE IF EXISTS "r_inv_admin"; CREATE TABLE "r_inv_admin" ( "uid" integer NOT NULL, "inv_id" integer NOT NULL, PRIMARY KEY ("uid", "inv_id"), CONSTRAINT "uid" FOREIGN KEY ("uid") REFERENCES "t_users" ("uid") ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT "inv_id" FOREIGN KEY ("inv_id") REFERENCES "t_inventories" ("id") ON DELETE CASCADE ON UPDATE CASCADE ); -- ---------------------------- -- Table structure for r_inv_imgs -- ---------------------------- DROP TABLE IF EXISTS "r_inv_imgs"; CREATE TABLE "r_inv_imgs" ( "inv_id" integer NOT NULL, "file_id" integer NOT NULL, PRIMARY KEY ("inv_id", "file_id"), CONSTRAINT "inv_id" FOREIGN KEY ("inv_id") REFERENCES "t_inventories" ("id") ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT "file_id" FOREIGN KEY ("file_id") REFERENCES "t_files" ("id") ON DELETE CASCADE ON UPDATE CASCADE ); -- ---------------------------- -- Table structure for r_inv_product -- ---------------------------- DROP TABLE IF EXISTS "r_inv_product"; CREATE TABLE "r_inv_product" ( "inv_id" integer NOT NULL, "pro_id" integer NOT NULL, "quantity" integer NOT NULL DEFAULT 0, PRIMARY KEY ("inv_id", "pro_id"), CONSTRAINT "inv_id" FOREIGN KEY ("inv_id") REFERENCES "t_inventories" ("id") ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT "pro_id" FOREIGN KEY ("pro_id") REFERENCES "t_products" ("id") ON DELETE CASCADE ON UPDATE CASCADE ); -- ---------------------------- -- Table structure for r_pro_imgs -- ---------------------------- DROP TABLE IF EXISTS "r_pro_imgs"; CREATE TABLE "r_pro_imgs" ( "pro_id" integer NOT NULL, "file_id" integer NOT NULL, PRIMARY KEY ("pro_id", "file_id"), CONSTRAINT "file_id" FOREIGN KEY ("file_id") REFERENCES "t_files" ("id") ON DELETE CASCADE ON UPDATE CASCADE ); -- ---------------------------- -- Table structure for r_user_avatar -- ---------------------------- DROP TABLE IF EXISTS "r_user_avatar"; CREATE TABLE "r_user_avatar" ( "uid" integer NOT NULL, "file_id" integer NOT NULL, PRIMARY KEY ("uid", "file_id"), CONSTRAINT "uid" FOREIGN KEY ("uid") REFERENCES "t_users" ("uid") ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT "file_id" FOREIGN KEY ("file_id") REFERENCES "t_files" ("id") ON DELETE CASCADE ON UPDATE CASCADE ); -- ---------------------------- -- Table structure for t_categories -- ---------------------------- DROP TABLE IF EXISTS "t_categories"; CREATE TABLE "t_categories" ( "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "title" text NOT NULL, "description" text NOT NULL DEFAULT '' ); -- ---------------------------- -- Table structure for t_files -- ---------------------------- DROP TABLE IF EXISTS "t_files"; CREATE TABLE "t_files" ( "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" text NOT NULL, "size" integer NOT NULL DEFAULT 0, "type" text NOT NULL DEFAULT '', "status" integer NOT NULL DEFAULT 0, "hash" text NOT NULL DEFAULT '', "quote_count" integer NOT NULL DEFAULT 0, "create_time" text NOT NULL DEFAULT '' ); -- ---------------------------- -- Table structure for t_inventories -- ---------------------------- DROP TABLE IF EXISTS "t_inventories"; CREATE TABLE "t_inventories" ( "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "topic" text NOT NULL, "description" text NOT NULL DEFAULT '', "location" text NOT NULL DEFAULT '' ); -- ---------------------------- -- Table structure for t_order_items -- ---------------------------- DROP TABLE IF EXISTS "t_order_items"; CREATE TABLE "t_order_items" ( "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "ord_id" integer NOT NULL, "pro_id" integer, "inv_id" integer NOT NULL, "title" text NOT NULL, "model" text NOT NULL DEFAULT '', "unit" text NOT NULL DEFAULT '', "count" integer NOT NULL DEFAULT 0, "price" real NOT NULL DEFAULT 0.00, "discount" real NOT NULL DEFAULT 1, "amount" real NOT NULL DEFAULT 0.00, "remarks" text NOT NULL DEFAULT '', "create_time" text NOT NULL DEFAULT '', CONSTRAINT "ord_id" FOREIGN KEY ("ord_id") REFERENCES "t_orders" ("id") ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT "inv_id" FOREIGN KEY ("inv_id") REFERENCES "t_inventories" ("id") ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT "pro_id" FOREIGN KEY ("pro_id") REFERENCES "t_products" ("id") ON DELETE SET NULL ON UPDATE CASCADE ); -- ---------------------------- -- Table structure for t_orders -- ---------------------------- DROP TABLE IF EXISTS "t_orders"; CREATE TABLE "t_orders" ( "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "seller" text NOT NULL, "receiver_name" text NOT NULL DEFAULT '', "receiver_phone" text NOT NULL DEFAULT '', "receiver_address" text NOT NULL DEFAULT '', "status" integer NOT NULL DEFAULT 0, "amount" real NOT NULL DEFAULT 0.00, "pay_from" integer NOT NULL DEFAULT 0, "pay_order_no" text NOT NULL DEFAULT '', "pay_time" text NOT NULL DEFAULT '', "is_invoice" integer NOT NULL DEFAULT 0, "invoice_client" text NOT NULL DEFAULT '', "remarks" text NOT NULL DEFAULT '', "create_time" text NOT NULL DEFAULT '' ); -- ---------------------------- -- Table structure for t_products -- ---------------------------- DROP TABLE IF EXISTS "t_products"; CREATE TABLE "t_products" ( "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "title" text NOT NULL, "cate_id" integer, "model" text NOT NULL, "brand" text NOT NULL DEFAULT '', "unit" text NOT NULL DEFAULT '', "price" real NOT NULL DEFAULT 0.00, "cost" real NOT NULL DEFAULT 0.00, "status" integer NOT NULL DEFAULT 0, "weight" real NOT NULL DEFAULT 0.00, "description" text NOT NULL DEFAULT '', "create_time" text NOT NULL DEFAULT '', CONSTRAINT "cate_id" FOREIGN KEY ("cate_id") REFERENCES "t_categories" ("id") ON DELETE SET NULL ON UPDATE CASCADE ); -- ---------------------------- -- Table structure for t_restock_items -- ---------------------------- DROP TABLE IF EXISTS "t_restock_items"; CREATE TABLE "t_restock_items" ( "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "res_id" integer NOT NULL, "pro_id" integer, "inv_id" integer NOT NULL, "title" text NOT NULL, "model" text NOT NULL DEFAULT '', "unit" text NOT NULL DEFAULT '', "count" integer NOT NULL DEFAULT 0, "cost" real NOT NULL DEFAULT 0.00, "amount" real NOT NULL DEFAULT 0.00, "remarks" text NOT NULL DEFAULT '', "create_time" text NOT NULL DEFAULT '', CONSTRAINT "res_id" FOREIGN KEY ("res_id") REFERENCES "t_restocks" ("id") ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT "inv_id" FOREIGN KEY ("inv_id") REFERENCES "t_inventories" ("id") ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT "pro_id" FOREIGN KEY ("pro_id") REFERENCES "t_products" ("id") ON DELETE SET NULL ON UPDATE CASCADE ); -- ---------------------------- -- Table structure for t_restocks -- ---------------------------- DROP TABLE IF EXISTS "t_restocks"; CREATE TABLE "t_restocks" ( "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "receiver" text NOT NULL DEFAULT '', "sender" text NOT NULL DEFAULT '', "sender_phone" text NOT NULL DEFAULT '', "amount" real NOT NULL DEFAULT 0.00, "remarks" text NOT NULL DEFAULT '', "create_time" text NOT NULL DEFAULT '' ); -- ---------------------------- -- Table structure for t_users -- ---------------------------- DROP TABLE IF EXISTS "t_users"; CREATE TABLE "t_users" ( "uid" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "username" text NOT NULL, "password" text NOT NULL, "nickname" text NOT NULL DEFAULT '', "gender" text NOT NULL DEFAULT '', "birth" text NOT NULL DEFAULT '', "phone" text NOT NULL DEFAULT '', "address" text NOT NULL DEFAULT '', "email" text NOT NULL DEFAULT '', "role" text NOT NULL DEFAULT '', "status" integer NOT NULL DEFAULT 0, "create_time" text NOT NULL DEFAULT '' ); PRAGMA foreign_keys = true;