zgo-backend/zgo-backend_DB.sql

459 lines
16 KiB
MySQL
Raw Normal View History

-- phpMyAdmin SQL Dump
-- version 5.2.1-4.fc40
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Jul 18, 2024 at 07:42 PM
-- Server version: 10.11.8-MariaDB
-- PHP Version: 8.2.21
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `zgodb`
--
-- --------------------------------------------------------
--
-- Table structure for table `block`
--
CREATE TABLE `block` (
`block_id` int(11) NOT NULL COMMENT 'Block Id number',
`block_confs` int(11) NOT NULL DEFAULT 0 COMMENT 'Block confirnations',
`block_network` varchar(15) NOT NULL DEFAULT '' COMMENT 'Block Network',
`block_height` int(11) NOT NULL DEFAULT 0 COMMENT 'Block Height',
`block_time` datetime NOT NULL COMMENT 'Block time'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Block header date';
-- --------------------------------------------------------
--
-- Table structure for table `blocktx`
--
CREATE TABLE `blocktx` (
`blocktx_block_id` int(11) NOT NULL COMMENT 'Block Tx parent',
`blocktx_id` int(11) NOT NULL DEFAULT 0 COMMENT 'Block Tx record Id',
`blocktx_txid` varchar(64) NOT NULL DEFAULT '' COMMENT 'Block Tx Id'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
--
-- Table structure for table `country`
--
CREATE TABLE `country` (
`country_code` varchar(5) NOT NULL COMMENT '2 Doigit Country Code',
`country_name` varchar(80) NOT NULL COMMENT 'Country unique name'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Coutry Codes and Names';
-- --------------------------------------------------------
--
-- Table structure for table `item`
--
CREATE TABLE `item` (
`item_owner_id` int(11) NOT NULL COMMENT 'Owner Id ',
`item_id` varchar(40) NOT NULL COMMENT 'Item Id',
`item_name` varchar(127) NOT NULL COMMENT 'Item name',
`item_description` varchar(300) NOT NULL DEFAULT '' COMMENT 'Item description',
`item_cost` double(12,4) NOT NULL DEFAULT 0.0000 COMMENT 'Item Unit price'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
--
-- Table structure for table `languages`
--
CREATE TABLE `languages` (
`encode_id` varchar(10) NOT NULL DEFAULT '' COMMENT 'Language encoding id',
`view_name` varchar(32) NOT NULL DEFAULT '' COMMENT 'View name that use this language',
`view_element` varchar(32) NOT NULL DEFAULT '' COMMENT 'Element name',
`view_element_text` varchar(4000) NOT NULL DEFAULT '' COMMENT 'Text to be displayed'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='ZGo Language translation database';
-- --------------------------------------------------------
--
-- Table structure for table `orderlines`
--
CREATE TABLE `orderlines` (
`orderline_orderid` int(11) NOT NULL DEFAULT 0 COMMENT 'Orderlines Order Id',
`orderline_line` int(11) NOT NULL DEFAULT 0 COMMENT 'Orderlines Line number',
`orderline_qty` int(11) NOT NULL DEFAULT 0 COMMENT 'Orderline item qty',
`orderline_name` varchar(250) NOT NULL DEFAULT '' COMMENT 'Orderline item description',
`orderline_cost` double(12,3) NOT NULL DEFAULT 0.000 COMMENT 'Orderline item cost'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Order contents';
-- --------------------------------------------------------
--
-- Table structure for table `orders`
--
CREATE TABLE `orders` (
`order_id` int(11) NOT NULL COMMENT 'Order Id',
`order_zaddress` varchar(300) NOT NULL COMMENT 'Order zcash address',
`order_session` varchar(64) NOT NULL DEFAULT '' COMMENT 'Order session id',
`order_timestamp` datetime NOT NULL COMMENT 'Order timestamp',
`order_closed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Order closed flag',
`order_currency` varchar(15) NOT NULL DEFAULT '' COMMENT 'Order currency',
`order_price` double(12,4) NOT NULL DEFAULT 0.0000 COMMENT 'Order ZEC price',
`order_total` double(12,4) NOT NULL DEFAULT 0.0000 COMMENT 'Order total amount',
`order_totalzec` double(14,8) NOT NULL DEFAULT 0.00000000 COMMENT 'Order total in ZEC',
`order_paid` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Order paid status',
`order_token` varchar(64) NOT NULL DEFAULT '' COMMENT 'Order token',
`order_extinv` varchar(64) NOT NULL DEFAULT '' COMMENT 'Order External Invoice',
`order_shortcode` varchar(64) NOT NULL DEFAULT '' COMMENT 'Order invoice shortcode',
`order_taxamount` double(12,3) NOT NULL DEFAULT 0.000 COMMENT 'Order tax amount',
`order_tipamount` double(12,3) NOT NULL DEFAULT 0.000 COMMENT 'Order tip amount',
`order_vatamount` double(12,3) NOT NULL DEFAULT 0.000 COMMENT 'Orcer VAT amount'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
--
-- Table structure for table `owner`
--
CREATE TABLE `owner` (
`owner_id` int(11) NOT NULL COMMENT 'Owner ID number',
`owner_co_name` varchar(127) NOT NULL DEFAULT '' COMMENT 'Company''s name',
`owner_firstname` varchar(127) NOT NULL COMMENT 'Owner''s first name',
`owner_lastname` varchar(127) NOT NULL COMMENT 'Owner''s last name',
`owner_email` varchar(127) NOT NULL COMMENT 'Owner''s email address',
`owner_street` varchar(127) NOT NULL COMMENT 'Owner''s street',
`owner_city` varchar(127) NOT NULL COMMENT 'Owner''s city',
`owner_state` varchar(127) NOT NULL COMMENT 'Owner''s state',
`owner_zipcode` varchar(40) NOT NULL COMMENT 'Owner''s zip code',
`owner_phone` varchar(25) NOT NULL COMMENT 'Owner''s phone number',
`owner_country` varchar(80) NOT NULL COMMENT 'Owner''s country',
`owner_website` varchar(125) NOT NULL COMMENT 'Owner''s website URL',
`owner_currency` varchar(15) NOT NULL COMMENT 'Owner''s currency',
`owner_zcaddress` varchar(500) NOT NULL DEFAULT '' COMMENT 'Owner''s zcash address',
`owner_usezats` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Use zats for display',
`owner_crmtoken` varchar(500) NOT NULL DEFAULT '' COMMENT 'Owner''s crm token',
`owner_usetax` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Use tax flag.',
`owner_taxvalue` double(12,3) NOT NULL DEFAULT 0.000 COMMENT 'tax rate to use',
`owner_usevat` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Use vat flag',
`owner_vat` double(12,3) NOT NULL DEFAULT 0.000 COMMENT 'vat rate to use',
`owner_payconf` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Confirm payment flag',
`owner_viewkey` varchar(500) NOT NULL DEFAULT '' COMMENT 'Viewing Key for payment confirmation',
`owner_invoices` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Use zgo invoices',
`owner_tips` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Activate tips',
`owner_paid` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'True if account is paid',
`owner_expiration` datetime NOT NULL DEFAULT current_timestamp() COMMENT 'Expiration date-time'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Owner''s account information';
-- --------------------------------------------------------
--
-- Table structure for table `payment`
--
CREATE TABLE `payment` (
`payment_id` int(11) NOT NULL COMMENT 'Payment Id',
`payment_delta` int(11) NOT NULL DEFAULT 0 COMMENT 'Payment delta',
`payment_done` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Payment done flag',
`payment_zaddress` varchar(300) NOT NULL DEFAULT '' COMMENT 'Payment zcash address',
`payment_session` varchar(127) NOT NULL DEFAULT '' COMMENT 'Payment session',
`payment_blocktime` int(11) NOT NULL DEFAULT 0 COMMENT 'Payment blocktime',
`payment_amount` double(12,3) NOT NULL DEFAULT 0.000 COMMENT 'Payment amount',
`payment_txid` varchar(127) NOT NULL DEFAULT '' COMMENT 'Payment transaction id',
`payment_memo` varchar(1000) NOT NULL DEFAULT '' COMMENT 'Payment Memo'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Payment table';
-- --------------------------------------------------------
--
-- Table structure for table `price`
--
CREATE TABLE `price` (
`price_id` int(11) NOT NULL COMMENT 'Price Id',
`price_delta` int(11) NOT NULL DEFAULT 0 COMMENT 'Price delta',
`price_done` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Price done flag',
`price_zaddress` varchar(300) NOT NULL DEFAULT '' COMMENT 'Price zcash address',
`price_session` varchar(127) NOT NULL DEFAULT '' COMMENT 'Price session',
`price_blocktime` int(11) NOT NULL DEFAULT 0 COMMENT 'Price blocktime',
`price_amount` double(12,3) NOT NULL DEFAULT 0.000 COMMENT 'Price amount',
`price_txid` varchar(127) NOT NULL DEFAULT '' COMMENT 'Price transaction id',
`price_memo` varchar(1000) NOT NULL DEFAULT '' COMMENT 'Price Memo'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Price table';
-- --------------------------------------------------------
--
-- Table structure for table `prozesion`
--
CREATE TABLE `prozesion` (
`pro_id` int(11) NOT NULL COMMENT 'Prosession record id',
`pro_zaddress` varchar(300) NOT NULL DEFAULT '' COMMENT 'Prosession zcash address',
`pro_expiration` datetime NOT NULL COMMENT 'Prosession expiration date/time',
`pro_closed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Prosession closed flag'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Prosessions table';
-- --------------------------------------------------------
--
-- Table structure for table `transaction`
--
CREATE TABLE `transaction` (
`tx_id` int(11) NOT NULL COMMENT 'Transaction ID',
`tx_zaddress` varchar(300) NOT NULL DEFAULT '' COMMENT 'Transaction Zcash Address',
`tx_expiration` datetime NOT NULL COMMENT 'Transaction Expiration Date/Time',
`tx_closed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Transaction Closed flag'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Transactions table';
-- --------------------------------------------------------
--
-- Table structure for table `user`
--
CREATE TABLE `user` (
`user_id` int(11) NOT NULL COMMENT 'User Id',
`user_zaddress` varchar(300) NOT NULL COMMENT 'User zcash address',
`user_session` varchar(100) NOT NULL COMMENT 'User session id',
`user_blocktime` datetime NOT NULL COMMENT 'User block time',
`user_pin` varchar(100) NOT NULL COMMENT 'User pin',
`user_validated` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'User validated'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='User session information';
-- --------------------------------------------------------
--
-- Table structure for table `wootoken`
--
CREATE TABLE `wootoken` (
`wootoken_id` int(11) NOT NULL COMMENT 'WooToken record Id',
`wootoken_owner_id` int(11) NOT NULL COMMENT 'WooToken owner id',
`wootoken_token` varchar(32) NOT NULL DEFAULT '' COMMENT 'WooToken token',
`wootoken_url` varchar(64) NOT NULL DEFAULT '' COMMENT 'WooToken URL'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='WooToken integration token table';
-- --------------------------------------------------------
--
-- Table structure for table `xero`
--
CREATE TABLE `xero` (
`xero_id` int(11) NOT NULL COMMENT 'Xero Id',
`xero_client_id` varchar(40) NOT NULL DEFAULT '' COMMENT 'Xero client id',
`xero_client_secret` varchar(64) NOT NULL DEFAULT '' COMMENT 'Xero client secret word'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
--
-- Table structure for table `xerotoken`
--
CREATE TABLE `xerotoken` (
`xerotoken_id` int(11) NOT NULL COMMENT 'Xero account id',
`xerotoken_zaddress` varchar(300) NOT NULL COMMENT 'Xero zcash address',
`xerotoken_access_token` varchar(1500) NOT NULL COMMENT 'Xero account access token',
`xerotoken_expires` int(11) NOT NULL COMMENT 'Xero token expiration ',
`xerotoken_refreshtoken` varchar(127) NOT NULL COMMENT 'Xero refresh token',
`xerotoken_accexpires` datetime NOT NULL COMMENT 'Xero account expire datetime',
`xerotoken_accCode` varchar(64) NOT NULL COMMENT 'Xero account code',
`xerotoken_refexpires` datetime NOT NULL COMMENT 'Xero reference expire datetime'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `block`
--
ALTER TABLE `block`
ADD PRIMARY KEY (`block_id`);
--
-- Indexes for table `blocktx`
--
ALTER TABLE `blocktx`
ADD KEY `fx_block_id` (`blocktx_block_id`);
--
-- Indexes for table `country`
--
ALTER TABLE `country`
ADD PRIMARY KEY (`country_code`),
ADD UNIQUE KEY `country_country_name_IDX` (`country_name`) USING BTREE;
--
-- Indexes for table `item`
--
ALTER TABLE `item`
ADD UNIQUE KEY `owner_item_ix` (`item_owner_id`,`item_id`);
--
-- Indexes for table `languages`
--
ALTER TABLE `languages`
ADD UNIQUE KEY `language_ix` (`encode_id`,`view_name`,`view_element`);
--
-- Indexes for table `orderlines`
--
ALTER TABLE `orderlines`
ADD KEY `fk_order_id` (`orderline_orderid`);
--
-- Indexes for table `orders`
--
ALTER TABLE `orders`
ADD PRIMARY KEY (`order_id`);
--
-- Indexes for table `owner`
--
ALTER TABLE `owner`
ADD PRIMARY KEY (`owner_id`);
--
-- Indexes for table `payment`
--
ALTER TABLE `payment`
ADD PRIMARY KEY (`payment_id`);
--
-- Indexes for table `price`
--
ALTER TABLE `price`
ADD PRIMARY KEY (`price_id`);
--
-- Indexes for table `prozesion`
--
ALTER TABLE `prozesion`
ADD PRIMARY KEY (`pro_id`),
ADD KEY `pro_zaddress` (`pro_zaddress`);
--
-- Indexes for table `transaction`
--
ALTER TABLE `transaction`
ADD PRIMARY KEY (`tx_id`),
ADD KEY `tx_zaddress` (`tx_zaddress`);
--
-- Indexes for table `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`user_id`),
ADD UNIQUE KEY `zaddress_ix` (`user_zaddress`);
--
-- Indexes for table `wootoken`
--
ALTER TABLE `wootoken`
ADD PRIMARY KEY (`wootoken_id`),
ADD KEY `wootoken_owner_ix` (`wootoken_owner_id`);
--
-- Indexes for table `xero`
--
ALTER TABLE `xero`
ADD PRIMARY KEY (`xero_id`);
--
-- Indexes for table `xerotoken`
--
ALTER TABLE `xerotoken`
ADD PRIMARY KEY (`xerotoken_id`),
ADD UNIQUE KEY `xero_zaddress_ix` (`xerotoken_zaddress`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `owner`
--
ALTER TABLE `owner`
MODIFY `owner_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Owner ID number';
--
-- AUTO_INCREMENT for table `payment`
--
ALTER TABLE `payment`
MODIFY `payment_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Payment Id';
--
-- AUTO_INCREMENT for table `price`
--
ALTER TABLE `price`
MODIFY `price_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Price Id';
--
-- AUTO_INCREMENT for table `transaction`
--
ALTER TABLE `transaction`
MODIFY `tx_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Transaction ID';
--
-- AUTO_INCREMENT for table `user`
--
ALTER TABLE `user`
MODIFY `user_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'User Id';
--
-- AUTO_INCREMENT for table `xerotoken`
--
ALTER TABLE `xerotoken`
MODIFY `xerotoken_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Xero account id';
--
-- Constraints for dumped tables
--
--
-- Constraints for table `blocktx`
--
ALTER TABLE `blocktx`
ADD CONSTRAINT `fx_block_id` FOREIGN KEY (`blocktx_block_id`) REFERENCES `block` (`block_id`);
--
-- Constraints for table `item`
--
ALTER TABLE `item`
ADD CONSTRAINT `fk_owner_id` FOREIGN KEY (`item_owner_id`) REFERENCES `owner` (`owner_id`);
--
-- Constraints for table `orderlines`
--
ALTER TABLE `orderlines`
ADD CONSTRAINT `fk_order_id` FOREIGN KEY (`orderline_orderid`) REFERENCES `orders` (`order_id`);
--
-- Constraints for table `wootoken`
--
ALTER TABLE `wootoken`
ADD CONSTRAINT `wootoken_owner_ix` FOREIGN KEY (`wootoken_owner_id`) REFERENCES `owner` (`owner_id`);
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;