rvv001 - zgo-backend database backend

Initial commit - Database definition using Persistent (in progress)
This commit is contained in:
Rene V. Vergara A. 2024-07-18 21:44:21 -04:00
parent a6d2426610
commit f3ba2f48da
2 changed files with 614 additions and 0 deletions

156
src/DB.hs Normal file
View file

@ -0,0 +1,156 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeApplications #-}
module DB where
import Control.Exception (throwIO)
import Control.Monad (forM_, when)
import Control.Monad.IO.Class (MonadIO, liftIO)
import Control.Monad.Logger (NoLoggingT, runNoLoggingT)
import Data.Bifunctor (bimap)
import qualified Data.ByteString as BS
import Data.HexString
import Data.List (group, sort)
import Data.Maybe (catMaybes, fromJust, isJust)
import Data.Pool (Pool)
import qualified Data.Text as T
import qualified Data.Text.Encoding as TE
import Data.Word
import Database.Esqueleto.Experimental
import qualified Database.Persist.Sqlite as PS
import Database.Persist.TH
share
[mkPersist sqlSettings, mkMigrate "migrateAll"]
[persistLowerCase|
ZgoBlock
block_id Int --Block Id number
block_confs Int default=0 -- Block confirnations
block_network String default="" -- Block Network
block_height Int default=0 -- Block Height
block_time Int default=0 -- Block time
UniqueBlock block_id
deriving Show Eq
ZgoBlockTx
blocktx_block_id Int --'Block Tx parent
blocktx_id Int -- Block Tx record Id
blocktx_txid String -- Block Tx Id
UniqueBlockTx blocktx_block_id blocktx_id
deriving Show Eq
ZgoCountry
country_code String -- Two Character Country Code
country_name String -- Country unique name
UniqueCountryCode country_code
deriving Show Eq
ZgoItem
item_owner_id Int -- Owner Id
item_id String -- Item Id
item_name String -- Item name',
item_description T.Text default="" -- Item description
item_cost Float default=0.0 -- Item Unit price
UniqueItemId item_owner item_id
deriving Show Eq
ZgoLanguages
encode_id String -- Language encoding id
view_name String default-"" -- View name that use this language'
view_element String default="" -- 'Element name
view_element_text T.Text default="" -- Text to be displayed'
UniqueLanguage encode_id view_name view_element
deriving Show Eq
ZgoOrders
order_id Int -- Order Id
order_zaddress T.Text -- Order zcash address
order_session T.Text -- Order session id
order_timestamp Int -- Order timestamp
order_closed Word8 -- Order closed flag
order_currency String -- Order currency
order_price Float default=0.0 -- Order ZEC price
order_total Float default=0.0 -- Order total amount
order_totalzec Float default=0.0 -- Order total in ZEC
order_paid Word8 default=0 -- Order paid status
order_token String default="" -- Order token
order_extinv String default="" -- Order External Invoice
order_shortcode String default='' -- Order invoice shortcode
order_taxamount Float default=0.0 -- Order tax amount
order_tipamount Float default=0.0 -- Order tip amount
order_vatamount Float default=0.0 -- Orcer VAT amount'
UniqueOrderId order_id
deriving Show Eq
ZgoOrderLines
orderline_orderid Int default=0 -- Orderlines Order Id
orderline_line Int default=0 -- Orderlines Line number
orderline_qty Int default=0 -- Orderline item qty
orderline_name T.Text default="" -- Orderline item description
orderline_cost Float default=0.0 -- Orderline item cost
UniqueOrderLine orderline_orderid orderline_line
deriving Show Eq
ZgoOwner
owner_id Int --'Owner ID number
owner_co_name String default="" -- Company''s name
owner_firstname String -- Owner's first name
owner_lastname String -- Owner's last name
owner_email String -- Owner's email address
owner_street String -- Owner's street
owner_city String -- Owner's city
owner_state String -- Owner's state
owner_zipcode String -- Owner's zip code
owner_phone String -- Owner's phone number
owner_country String -- Owner's country
owner_website String -- Owner's website URL
owner_currency String -- Owner's currency',
owner_zcaddress String -- Owner's zcash address
owner_usezats Word8 -- Use zats for display
owner_crmtoken T.Text -- Owner's crm token
owner_usetax Word8 -- Use tax flag
owner_taxvalue Float -- Tax rate to use
owner_usevat Word8 -- Use vat flag
owner_vat Float -- Vat rate to use
owner_payconf Word8 -- Confirm payment flag
owner_viewkey T.Text -- Viewing Key for payment confirmation
owner_invoices Word8 -- Use zgo invoices
owner_tips Word8 -- Activate tips
owner_paid Word8 -- True if account is paid
owner_expiration Int -- Expiration date-time
UniqueOwnerId owner_id
UniqueOwnerZcashAddr owner_zcaddress
deriving Show Eq
ZgoPayment
payment_id Int -- Payment Id
payment_delta Int -- Payment delta
payment_done Word8 -- Payment done flag
payment_zaddress T.Text -- Payment zcash address
payment_session String default="" -- Payment session
payment_blocktime Int default=0 -- Payment blocktime
payment_amount Float default=0.0 -- Payment amount
payment_txid String default ="" -- Payment transaction id
payment_memo T.Text default="" -- Payment Memo
UniquePaymentId payment_id
deriving Show Eq
ZgoPrice
price_id Int -- Price Id
price_delta Int default=0 -- Price delta
price_done Word8 default=0 -- Price done flag
price_zaddress T.Text default="" -- Price zcash address
price_session String default="" -- Price session
price_blocktime Int default=0 -- Price blocktime
price_amount Float default=0.0 -- Price amount
price_txid String default="" -- Price transaction id
price_memo T.Text default="" -- Price Memo
UniquePriceId price_id
deriving Show Eq

458
zgo-backend_DB.sql Normal file
View file

@ -0,0 +1,458 @@
-- 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 */;