deepkit-framework icon indicating copy to clipboard operation
deepkit-framework copied to clipboard

[orm] Migrate validator constraints to SQL schemas

Open marcj opened this issue 4 years ago • 0 comments

When having an entity like

interface User {
    id: number & PrimaryKey & AutoIncrement;
    username: string & MinLength<3>;
}

then the generated SQL should contain the minLength and other supported constraints


CREATE TABLE `user` (
        `id` double NOT NULL AUTO_INCREMENT,
        `username` longtext NOT NULL,
        PRIMARY KEY (`id`),
        CONSTRAINT username_minLength CHECK (LENGTH(username) >= 3)
    )

marcj avatar Aug 12 '21 10:08 marcj