Skip to content

Generated table for enumeration column type  #1598

Open
@SchweinchenFuntik

Description

@SchweinchenFuntik

Generate dictionary table for Enum.

Motivation: for the correctness of the scheme, especially useful for other systems that will also work with the database

enum class AccountType { DEBIT, CREDIT }

object Accounts : Table() {
    val type = enumeration("type", AccountType::class)
}

We get in the database:

CREATE TABLE ACCOUNT_TYPE(ID INT, NAME VARCHAR);

ALTER TABLE ACCOUNT ADD CONSTRAINT FX_ACCOUNT_ACCOUNT_TYPE_ID FOREIGN KEY (TYPE) REFERENCES ACCOUNT_TYPE(ID);

INSERT INTO ACCOUNT_TYPE(ID, NAME) VALUES (1, 'DEBIT');
INSERT INTO ACCOUNT_TYPE(ID, NAME) VALUES (2, 'CREDIT');

make optional

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions