CREATE TABLE PUBLIC.FLW_EVENT_DEPLOYMENT (
                                             ID_ VARCHAR(255) NOT NULL,
                                             NAME_ VARCHAR(255),
                                             CATEGORY_ VARCHAR(255),
                                             DEPLOY_TIME_ timestamp,
                                             TENANT_ID_ VARCHAR(255),
                                             PARENT_DEPLOYMENT_ID_ VARCHAR(255),
                                             CONSTRAINT FLW_EVENT_DEPLOYMENT_PK PRIMARY KEY (ID_)
);

create table PUBLIC.FLW_CHANNEL_DEFINITION
(
    ID_            VARCHAR(255) not null
        constraint "flw_channel_definition_pk"
            primary key,
    NAME_          VARCHAR(255),
    VERSION_       INT4,
    KEY_           VARCHAR(255),
    CATEGORY_      VARCHAR(255),
    DEPLOYMENT_ID_ VARCHAR(255),
    CREATE_TIME_   TIMESTAMP,
    TENANT_ID_ VARCHAR(255),
    RESOURCE_NAME_ VARCHAR(255),
    DESCRIPTION_ VARCHAR(255),
    TYPE_ VARCHAR(255),
    IMPLEMENTATION_ VARCHAR(255)
);
CREATE UNIQUE INDEX ACT_IDX_CHANNEL_DEF_UNIQ  ON FLW_CHANNEL_DEFINITION(KEY_,VERSION_,TENANT_ID_);


create table FLW_EVENT_DEFINITION
(
    ID_            VARCHAR(255) not null
        constraint "flw_event_definition_pk"
            primary key,
    NAME_          VARCHAR(255),
    VERSION_       INT4,
    KEY_           VARCHAR(255),
    CATEGORY_      VARCHAR(255),
    DEPLOYMENT_ID_ VARCHAR(255),
    TENANT_ID_     VARCHAR(255),
    RESOURCE_NAME_ VARCHAR(255),
    DESCRIPTION_   VARCHAR(255)
);
CREATE UNIQUE INDEX ACT_IDX_EVENT_DEF_UNIQ  ON FLW_EVENT_DEFINITION(KEY_,VERSION_,TENANT_ID_);


create table FLW_EVENT_RESOURCE
(
    ID_             VARCHAR(255) not null
        constraint "flw_event_resource_pk"
            primary key,
    NAME_           VARCHAR(255),
    DEPLOYMENT_ID_  VARCHAR(255),
    RESOURCE_BYTES_ BLOB
);
