dbml icon indicating copy to clipboard operation
dbml copied to clipboard

Add support for custom constraints

Open iloudaros opened this issue 2 years ago • 1 comments

for example, how can I use dbml to give this description :

CREATE TABLE `MyTable` (
  `id` INT PRIMARY KEY AUTO_INCREMENT,
  `foreignKey1` INT,
  `foreignKey2` INT,
  CONSTRAINT `check_foreign_key` CHECK (`foreignKey1` IN (SELECT `id` FROM `OtherTable1`) OR `foreignKey2` IN (SELECT `id` FROM `OtherTable2`)))
);

iloudaros avatar Dec 11 '23 13:12 iloudaros

Hi,

For the columns and table, you can define dbml like this (However, there's currently no equivalent dbml syntax for CHECK CONTRAINTS):

Table "MyTable" {
  "id" INT [pk, increment]
  "foreignKey1" INT
  "foreignKey2" INT
}

NQPhuc avatar Dec 12 '23 08:12 NQPhuc