Skip to content

Commit 19a9677

Browse files
Merge pull request #69 from PSMRI/migration/dynamic_form
Migration/dynamic form
2 parents 38905c8 + 0c3719a commit 19a9677

1 file changed

Lines changed: 74 additions & 0 deletions

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
-- ========================================
2+
-- Migration: Create New Tables
3+
-- ========================================
4+
USE db_iemr;
5+
6+
-------------------------------------------------------------
7+
-- form_module
8+
-------------------------------------------------------------
9+
CREATE TABLE IF NOT EXISTS `form_module` (
10+
`id` bigint NOT NULL AUTO_INCREMENT,
11+
`module_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
12+
`created_at` datetime DEFAULT CURRENT_TIMESTAMP,
13+
PRIMARY KEY (`id`)
14+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
15+
16+
-------------------------------------------------------------
17+
-- form_master
18+
-------------------------------------------------------------
19+
CREATE TABLE IF NOT EXISTS `form_master` (
20+
`id` bigint NOT NULL AUTO_INCREMENT,
21+
`form_id` varchar(100) NOT NULL,
22+
`form_name` varchar(255) NOT NULL,
23+
`module_id` bigint DEFAULT NULL,
24+
`created_at` datetime DEFAULT CURRENT_TIMESTAMP,
25+
`version` int DEFAULT 1,
26+
PRIMARY KEY (`id`),
27+
UNIQUE KEY (`form_id`),
28+
KEY `fk_module` (`module_id`),
29+
CONSTRAINT `fk_module` FOREIGN KEY (`module_id`) REFERENCES `form_module` (`id`) ON DELETE CASCADE
30+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
31+
32+
-------------------------------------------------------------
33+
-- form_fields
34+
-------------------------------------------------------------
35+
CREATE TABLE IF NOT EXISTS `form_fields` (
36+
`id` bigint NOT NULL AUTO_INCREMENT,
37+
`form_id` varchar(100) NOT NULL,
38+
`section_title` varchar(255),
39+
`field_id` varchar(100) NOT NULL,
40+
`label` varchar(255),
41+
`type` varchar(100),
42+
`is_required` tinyint(1),
43+
`default_value` varchar(255),
44+
`placeholder` varchar(255),
45+
`options` longtext,
46+
`validation` longtext,
47+
`conditional` longtext,
48+
`sequence` int,
49+
`created_at` datetime DEFAULT CURRENT_TIMESTAMP,
50+
`is_visible` tinyint(1) DEFAULT 0,
51+
PRIMARY KEY (`id`),
52+
KEY `fk_form` (`form_id`),
53+
CONSTRAINT `fk_form` FOREIGN KEY (`form_id`) REFERENCES `form_master` (`form_id`) ON DELETE CASCADE,
54+
CONSTRAINT `form_fields_chk_1` CHECK (json_valid(`options`)),
55+
CONSTRAINT `form_fields_chk_2` CHECK (json_valid(`validation`)),
56+
CONSTRAINT `form_fields_chk_3` CHECK (json_valid(`conditional`))
57+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
58+
59+
-------------------------------------------------------------
60+
-- m_translation
61+
-------------------------------------------------------------
62+
CREATE TABLE IF NOT EXISTS `m_translation` (
63+
`id` bigint NOT NULL AUTO_INCREMENT,
64+
`label_key` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
65+
`english` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL ,
66+
`hindi_translation` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL ,
67+
`is_active` tinyint(1) NOT NULL DEFAULT 1,
68+
`created_by` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
69+
`created_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
70+
`updated_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
71+
`assamese_translation` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
72+
PRIMARY KEY (`id`),
73+
UNIQUE KEY `label_key` (`label_key`)
74+
) ENGINE=InnoDB AUTO_INCREMENT=452 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

0 commit comments

Comments
 (0)