Compare commits

...

8 commits

Author SHA1 Message Date
d743233c4b rvv001 - DB.hs - Relational database model created for Zgo 2024-09-14 19:48:11 -04:00
b9cf0bcb9f Merge branch 'rav001' into rvv001 2024-08-12 12:27:31 -04:00
8be9215f04
Correct types 2024-08-12 10:42:30 -05:00
e24581eb5d
Remove ID fields
Persistent adds them automatically
2024-08-12 09:23:36 -05:00
9b48ce2b68
Remove comments from QuasiQuote 2024-08-12 08:58:45 -05:00
17f6d557a1
Add Persistent dependencies 2024-08-12 08:58:07 -05:00
0f03ad32f2 rvv001 - zgo-backend database module
database structure v0.1 defined in DB.hs
2024-07-19 10:17:54 -04:00
f3ba2f48da rvv001 - zgo-backend database backend
Initial commit - Database definition using Persistent (in progress)
2024-07-18 21:44:21 -04:00
4 changed files with 707 additions and 0 deletions

View file

@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.9.0]
### Added
- Relational database model (DB.hs) version 0.1
## [1.8.1]
### Changed

236
src/DB.hs Normal file
View file

@ -0,0 +1,236 @@
{-# 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.Aeson
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 qualified Data.Text as T
import qualified Data.Text.Encoding as TE
import Data.Time (UTCTime(..))
import Data.UUID (UUID)
import Data.Word
import Database.Esqueleto.Experimental
import qualified Database.Persist.MySQL as PM
import Database.Persist.TH
newtype UuidDB = UuidDB
{ getUUID :: UUID
} deriving newtype (Eq, Show, Read, ToJSON, FromJSON)
derivePersistFieldJSON "UuidDB"
newtype HexStringDB = HexStringDB
{ getHex :: HexString
} deriving newtype (Eq, Show, Read)
derivePersistField "HexStringDB"
share
[mkPersist sqlSettings, mkMigrate "migrateAll"]
[persistLowerCase|
-- |
-- | Block table (ref. #49)
-- |
ZgoBlock json
confs Int default=0
network String default=""
height Int default=0
time Int default=0
deriving Show Eq
-- | Block transactions table (child table)
ZgoBlockTx
blockId ZgoBlockId
txid String
deriving Show Eq
-- |
-- | Coutry codes table (ref. 0.50)
-- |
ZgoCountry json
code T.Text
name T.Text
UniqueCountryCode code
deriving Show Eq
-- |
-- | Coutry Items table )ref. #51)
-- } (Owner's Child table)
-- |
ZgoItem json
owner ZgoOwnerId
name T.Text
description T.Text default=""
cost Double default=0.0
deriving Show Eq
-- |
-- | Langauages table (ref #52)
-- |
ZgoLanguages
encode_id T.Text
name T.Text default-""
element T.Text default=""
element_text T.Text default=""
deriving Show Eq
-- |
-- | Orders table (ref #53)
-- | (Owner child table)
-- |
ZgoOrder json
owner ZgoOwnerId
zaddress T.Text
session ZgoUserId
timestamp Int
closed Word8
currency T.Text
price Double
total Double
totalZec Double
paid Bool
token T.Text default=""
externalInvoice T.Text default=""
shortcode T.Text
taxamount Double
tipamount Double
vatamount Double
deriving Show Eq
-- |
-- | Order Lines table
-- | (Order child table)
-- |
ZgoOrderLines
orderId ZgoOrderId
qty Int default=0
name T.Text default=""
cost Double default=0.0
deriving Show Eq
-- |
-- | Owner table (ref. #54)
-- |
ZgoOwner
co_name T.Text
firstname T.Text
lastname T.Text
email T.Text
street T.Text
city T.Text
state T.Text
zipcode T.Text
phone T.Text
country T.Text
website T.Text
currency T.Text
zaddress T.Text
usezats Bool
crmtoken T.Text
usetax Bool
taxvalue Double
usevat Bool
vat Double
payconf Bool
viewkey T.Text
invoices Bool
tips Bool
paid Bool
expiration UTCTime
deriving Show Eq
-- |
-- | Payment Table (ref. #55)
-- |
ZgoPayment
delta Int
done Bool
zaddress T.Text
session UuidDB
blocktime Int default=0
amount Double default=0.0
txid HexStringDB
memo T.Text
deriving Show Eq
-- |
-- | Price Table (ref. #56)
-- |
ZgoPrice
currency T.Text
price Double default=0.0
timestamp UTCTime
deriving Show Eq
-- |
-- | ProSesion Table (ref. #57)
-- |
ZgoProSesion
zaddress T.Text default=""
expiration UTCTime
closed Bool
deriving Show Eq
-- |
-- | Transaction table (ref. # 58)
-- |
ZgoTransaction
zaddress T.Text
session T.Text
confirmations Int default=0
blocktime Int default=0
amount Double default=0.00
txid T.Text
memo T.Text
deriving Show Eq
-- |
-- | User table (ref. 59)
-- |
ZgoUser json
owner ZgoOwnerId
session UuidDB
blocktime Int
pin T.Text
validated Bool
deriving Show Eq
-- |
-- | User table (ref. 60)
-- |
ZgoWooToken
owner ZgoOwnerId
token T.Text
url T.Text
deriving Show Eq
-- |
-- | User table (ref. 61)
-- |
ZgoXero
client_id T.Text default=""
client_secret T.Text default=""
deriving Show Eq
-- |
-- | User table (ref. 62)
-- |
ZgoXeroToken
zaddress T.Text
access_token T.Text
expires UTCTime
refreshtoken T.Text
accexpires Int
accCode T.Text
refexpires UTCTime
deriving Show Eq
|]

View file

@ -33,6 +33,7 @@ library
Xero
ZGoBackend
ZGoTx
DB
hs-source-dirs:
src
build-depends:
@ -47,6 +48,10 @@ library
, configurator
, containers
, crypto-rng
, esqueleto
, persistent
, persistent-mysql
, persistent-template
, ghc-prim
, hexstring
, http-conduit
@ -54,6 +59,7 @@ library
, jwt
, megaparsec
, memory
, monad-logger
, mongoDB
, network
, quickcheck-instances

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 */;