aboutsummaryrefslogtreecommitdiffstats
path: root/db/init/update.sql
diff options
context:
space:
mode:
authorRan Guin <[email protected]>2021-07-15 12:49:13 -0700
committerRan Guin <[email protected]>2021-07-15 12:49:13 -0700
commitd709971459911dd98d47b32630a97bd6eefd74a2 (patch)
tree9d45b8c0bb714f5daf1b6ba96d94bb556e18729d /db/init/update.sql
parent33f0c7d44881b7306ae967a3c835ed243dea2ad1 (diff)
downloadcoinos-server-d709971459911dd98d47b32630a97bd6eefd74a2.tar.gz
coinos-server-d709971459911dd98d47b32630a97bd6eefd74a2.zip
add db init for rebuilding prod from scratch
Diffstat (limited to 'db/init/update.sql')
-rw-r--r--db/init/update.sql44
1 files changed, 44 insertions, 0 deletions
diff --git a/db/init/update.sql b/db/init/update.sql
new file mode 100644
index 00000000..a99decac
--- /dev/null
+++ b/db/init/update.sql
@@ -0,0 +1,44 @@
+
+CREATE TABLE `waiting_list` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `email` varchar(255) DEFAULT NULL,
+ `phone` varchar(255) DEFAULT NULL,
+ `created_at` datetime DEFAULT NULL,
+ `updated_at` datetime DEFAULT NULL,
+ `status` enum('pending','contacted','registered') DEFAULT NULL,
+ `user_id` int(11),
+ KEY `user` (`user_id`),
+ FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=latin1;
+
+CREATE TABLE `referrals` (
+ `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `token` varchar(255) DEFAULT NULL,
+ `expiry` date DEFAULT NULL,
+ `status` enum('pending','active','expired','cancelled') DEFAULT NULL,
+ `sponsor_id` int(11) NOT NULL,
+ `user_id` int(11) DEFAULT NULL,
+ `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `token` (`token`),
+ CONSTRAINT `sponsor` FOREIGN KEY (sponsor_id) REFERENCES users (`id`),
+ CONSTRAINT `sponsored` FOREIGN KEY (`user_id`) REFERENCES users (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=latin1;
+
+ALTER TABLE invoices ADD CONSTRAINT `invoice_user` FOREIGN KEY (user_id) REFERENCES users (id);
+ALTER TABLE invoices ADD CONSTRAINT `invoice_account` FOREIGN KEY (account_id) REFERENCES accounts (id);
+
+ALTER TABLE orders ADD CONSTRAINT `order_user` FOREIGN KEY (user_id) REFERENCES users (id);
+
+ALTER TABLE payments ADD CONSTRAINT `payment_user` FOREIGN KEY (user_id) REFRENCES users (id);
+ALTER TABLE payments ADD CONSTRAINT `payment_account` FOREIGN KEY (account_id) REFERENCES accounts (id);
+
+ALTER TABLE deposits ADD CONSTRAINT `deposit_user` FOREIGN KEY (user_id) REFERENCES users (id);
+
+ALTER TABLE withdrawals ADD CONSTRAINT `withdrawal_user` FOREIGN KEY (user_id) REFERENCES users (id);
+
+ALTER TABLE accounts ADD CONSTRAINT `account_user` FOREIGN KEY (user_id) REFERENCES accounts (id);
+ALTER TABLE users ADD CONSTRAINT `user_account` FOREIGN KEY (account_id) REFERENCES accounts (id);
+