From 03c8f47cf010a07fb472ce8b6f4f8802913297e0 Mon Sep 17 00:00:00 2001 From: Andrew Malsbury Date: Mon, 9 Oct 2023 20:27:09 +0000 Subject: [PATCH] added account types table --- db.sql | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/db.sql b/db.sql index 520b39e0..e6e1c063 100644 --- a/db.sql +++ b/db.sql @@ -28,14 +28,29 @@ CREATE TABLE `accounts` ( `opening_balance` decimal(15,2) NOT NULL DEFAULT 0.00, `account_currency_code` varchar(200) NOT NULL, `account_notes` text DEFAULT NULL, - `account_type` int(6) NOT NULL DEFAULT 11, + `account_type` int(6) NOT NULL DEFAULT NULL, `account_created_at` datetime NOT NULL DEFAULT current_timestamp(), `account_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), `account_archived_at` datetime DEFAULT NULL, - PRIMARY KEY (`account_id`) + PRIMARY KEY (`account_id`), + CONSTRAINT `fk_accounts_account_type_id` FOREIGN KEY (`account_type`) REFERENCES `account_types` (`account_type_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; + +DROP TABLE IF EXISTS `account_types`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `account_types` ( + `account_type_id` int(11) NOT NULL AUTO_INCREMENT, + `account_type_name` varchar(200) NOT NULL, + `account_type_description` text DEFAULT NULL, + `account_type_created_at` datetime NOT NULL DEFAULT current_timestamp(), + `account_type_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), + `account_type_archived_at` datetime DEFAULT NULL, + PRIMARY KEY (`account_type_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + -- -- Table structure for table `api_keys` --