leaf icon indicating copy to clipboard operation
leaf copied to clipboard

How to create a .yml schema file for foreign key contraints

Open mtech2008 opened this issue 8 months ago • 0 comments

Hi, I have a following sql and I want to write a .yml schema file.

CREATE TABLE Programs ( program_id int(11) NOT NULL AUTO_INCREMENT, program_name varchar(255) DEFAULT NULL, program_code varchar(50) DEFAULT NULL, duration varchar(50) DEFAULT NULL, department_id int(11) DEFAULT NULL, PRIMARY KEY (program_id), UNIQUE KEY program_name (program_name), UNIQUE KEY program_code (program_code), KEY department_id (department_id), CONSTRAINT programs_ibfk_1 FOREIGN KEY (department_id) REFERENCES departments (department_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

How could I do that?

The following creates a table without constraints:

increments: false table: programs columns: program_id: type: integer primary: true autoIncrement: true program_name: type: string length: 255 unique: true nullable: true program_code: type: string length: 50 unique: true nullable: true duration: type: string length: 50 nullable: true department_id: type: integer index: true nullable: true

mtech2008 avatar May 04 '25 14:05 mtech2008