evolutions.default.1.sql Maven / Gradle / Ivy
The newest version!
# --- Created by Ebean DDL
# To stop Ebean DDL generation, remove this comment and start using Evolutions
# --- !Ups
create table authentication (
id bigint auto_increment not null,
user_name varchar(255),
token varchar(255),
constraint uq_authentication_user_name unique (user_name),
constraint pk_authentication primary key (id)
);
create table bundle (
id bigint auto_increment not null,
name varchar(255),
owner_id bigint,
constraint uq_bundle_name unique (name),
constraint pk_bundle primary key (id)
);
create table deployment (
id bigint auto_increment not null,
heartbeat timestamp,
deployment_owner varchar(255),
initiator varchar(255),
manifest_history_id bigint,
state varchar(11),
start timestamp,
finished timestamp,
constraint ck_deployment_state check ( state in ('FAILED','RUNNING','NOT_STARTED','SUCCEEDED')),
constraint pk_deployment primary key (id)
);
create table deployment_log (
id bigint auto_increment not null,
host_id bigint,
message varchar(255),
deployment_id bigint,
log_time timestamp,
constraint pk_deployment_log primary key (id)
);
create table environment (
id bigint auto_increment not null,
name varchar(255),
owner_id bigint,
parent_id bigint,
environment_type varchar(6),
config varchar(255),
version bigint not null,
constraint ck_environment_environment_type check ( environment_type in ('ROLLER','DOCKER','RPM')),
constraint uq_environment_name unique (name),
constraint pk_environment primary key (id)
);
create table host (
id bigint auto_increment not null,
name varchar(255),
hostclass_id bigint,
constraint uq_host_name unique (name),
constraint pk_host primary key (id)
);
create table host_deployment (
id bigint auto_increment not null,
host_id bigint,
deployment_id bigint,
state varchar(11),
state_detail varchar(255),
heartbeat timestamp,
started timestamp,
finished timestamp,
constraint ck_host_deployment_state check ( state in ('FAILED','RUNNING','NOT_STARTED','SUCCEEDED')),
constraint pk_host_deployment primary key (id)
);
create table hostclass (
id bigint auto_increment not null,
name varchar(255),
parent_id bigint,
constraint uq_hostclass_name unique (name),
constraint pk_hostclass primary key (id)
);
create table hostclass_stage (
hostclass_id bigint not null,
stage_id bigint not null,
constraint pk_hostclass_stage primary key (hostclass_id,stage_id)
);
create table inflight_deployment (
id bigint auto_increment not null,
constraint pk_inflight_deployment primary key (id)
);
create table manifest (
id bigint auto_increment not null,
created_by varchar(255),
environment_id bigint,
version varchar(255),
created_at timestamp not null,
constraint pk_manifest primary key (id)
);
create table manifest_package_version (
manifest_id bigint not null,
package_version_id bigint not null,
constraint pk_manifest_package_version primary key (manifest_id,package_version_id)
);
create table manifest_history (
id bigint auto_increment not null,
manifest_id bigint,
stage_id bigint,
start timestamp,
finish timestamp,
config varchar(255),
constraint pk_manifest_history primary key (id)
);
create table owner (
id bigint auto_increment not null,
org_name varchar(255),
constraint uq_owner_org_name unique (org_name),
constraint pk_owner primary key (id)
);
create table package (
id bigint auto_increment not null,
name varchar(255),
constraint uq_package_name unique (name),
constraint pk_package primary key (id)
);
create table package_version (
id bigint auto_increment not null,
pkg_id bigint,
type varchar(255),
repository varchar(255),
version varchar(255),
description varchar(255),
constraint uq_package_version_repository_pkg_id_version unique (repository,pkg_id,version),
constraint pk_package_version primary key (id)
);
create table stage (
id bigint auto_increment not null,
name varchar(255),
environment_id bigint,
config varchar(255),
version bigint not null,
constraint uq_stage_environment_id_name unique (environment_id,name),
constraint pk_stage primary key (id)
);
create table stage_hostclass (
stage_id bigint not null,
hostclass_id bigint not null,
constraint pk_stage_hostclass primary key (stage_id,hostclass_id)
);
create table user_membership (
id bigint auto_increment not null,
user_name varchar(255),
org_id bigint,
constraint uq_user_membership_user_name_org_id unique (user_name,org_id),
constraint pk_user_membership primary key (id)
);
alter table bundle add constraint fk_bundle_owner_id foreign key (owner_id) references owner (id) on delete restrict on update restrict;
create index ix_bundle_owner_id on bundle (owner_id);
alter table deployment add constraint fk_deployment_manifest_history_id foreign key (manifest_history_id) references manifest_history (id) on delete restrict on update restrict;
create index ix_deployment_manifest_history_id on deployment (manifest_history_id);
alter table deployment_log add constraint fk_deployment_log_host_id foreign key (host_id) references host (id) on delete restrict on update restrict;
create index ix_deployment_log_host_id on deployment_log (host_id);
alter table deployment_log add constraint fk_deployment_log_deployment_id foreign key (deployment_id) references deployment (id) on delete restrict on update restrict;
create index ix_deployment_log_deployment_id on deployment_log (deployment_id);
alter table environment add constraint fk_environment_owner_id foreign key (owner_id) references owner (id) on delete restrict on update restrict;
create index ix_environment_owner_id on environment (owner_id);
alter table environment add constraint fk_environment_parent_id foreign key (parent_id) references environment (id) on delete restrict on update restrict;
create index ix_environment_parent_id on environment (parent_id);
alter table host add constraint fk_host_hostclass_id foreign key (hostclass_id) references hostclass (id) on delete restrict on update restrict;
create index ix_host_hostclass_id on host (hostclass_id);
alter table host_deployment add constraint fk_host_deployment_host_id foreign key (host_id) references host (id) on delete restrict on update restrict;
create index ix_host_deployment_host_id on host_deployment (host_id);
alter table host_deployment add constraint fk_host_deployment_deployment_id foreign key (deployment_id) references deployment (id) on delete restrict on update restrict;
create index ix_host_deployment_deployment_id on host_deployment (deployment_id);
alter table hostclass add constraint fk_hostclass_parent_id foreign key (parent_id) references hostclass (id) on delete restrict on update restrict;
create index ix_hostclass_parent_id on hostclass (parent_id);
alter table hostclass_stage add constraint fk_hostclass_stage_hostclass foreign key (hostclass_id) references hostclass (id) on delete restrict on update restrict;
create index ix_hostclass_stage_hostclass on hostclass_stage (hostclass_id);
alter table hostclass_stage add constraint fk_hostclass_stage_stage foreign key (stage_id) references stage (id) on delete restrict on update restrict;
create index ix_hostclass_stage_stage on hostclass_stage (stage_id);
alter table manifest add constraint fk_manifest_environment_id foreign key (environment_id) references environment (id) on delete restrict on update restrict;
create index ix_manifest_environment_id on manifest (environment_id);
alter table manifest_package_version add constraint fk_manifest_package_version_manifest foreign key (manifest_id) references manifest (id) on delete restrict on update restrict;
create index ix_manifest_package_version_manifest on manifest_package_version (manifest_id);
alter table manifest_package_version add constraint fk_manifest_package_version_package_version foreign key (package_version_id) references package_version (id) on delete restrict on update restrict;
create index ix_manifest_package_version_package_version on manifest_package_version (package_version_id);
alter table manifest_history add constraint fk_manifest_history_manifest_id foreign key (manifest_id) references manifest (id) on delete restrict on update restrict;
create index ix_manifest_history_manifest_id on manifest_history (manifest_id);
alter table manifest_history add constraint fk_manifest_history_stage_id foreign key (stage_id) references stage (id) on delete restrict on update restrict;
create index ix_manifest_history_stage_id on manifest_history (stage_id);
alter table package_version add constraint fk_package_version_pkg_id foreign key (pkg_id) references package (id) on delete restrict on update restrict;
create index ix_package_version_pkg_id on package_version (pkg_id);
alter table stage add constraint fk_stage_environment_id foreign key (environment_id) references environment (id) on delete restrict on update restrict;
create index ix_stage_environment_id on stage (environment_id);
alter table stage_hostclass add constraint fk_stage_hostclass_stage foreign key (stage_id) references stage (id) on delete restrict on update restrict;
create index ix_stage_hostclass_stage on stage_hostclass (stage_id);
alter table stage_hostclass add constraint fk_stage_hostclass_hostclass foreign key (hostclass_id) references hostclass (id) on delete restrict on update restrict;
create index ix_stage_hostclass_hostclass on stage_hostclass (hostclass_id);
alter table user_membership add constraint fk_user_membership_org_id foreign key (org_id) references owner (id) on delete restrict on update restrict;
create index ix_user_membership_org_id on user_membership (org_id);
# --- !Downs
alter table bundle drop constraint if exists fk_bundle_owner_id;
drop index if exists ix_bundle_owner_id;
alter table deployment drop constraint if exists fk_deployment_manifest_history_id;
drop index if exists ix_deployment_manifest_history_id;
alter table deployment_log drop constraint if exists fk_deployment_log_host_id;
drop index if exists ix_deployment_log_host_id;
alter table deployment_log drop constraint if exists fk_deployment_log_deployment_id;
drop index if exists ix_deployment_log_deployment_id;
alter table environment drop constraint if exists fk_environment_owner_id;
drop index if exists ix_environment_owner_id;
alter table environment drop constraint if exists fk_environment_parent_id;
drop index if exists ix_environment_parent_id;
alter table host drop constraint if exists fk_host_hostclass_id;
drop index if exists ix_host_hostclass_id;
alter table host_deployment drop constraint if exists fk_host_deployment_host_id;
drop index if exists ix_host_deployment_host_id;
alter table host_deployment drop constraint if exists fk_host_deployment_deployment_id;
drop index if exists ix_host_deployment_deployment_id;
alter table hostclass drop constraint if exists fk_hostclass_parent_id;
drop index if exists ix_hostclass_parent_id;
alter table hostclass_stage drop constraint if exists fk_hostclass_stage_hostclass;
drop index if exists ix_hostclass_stage_hostclass;
alter table hostclass_stage drop constraint if exists fk_hostclass_stage_stage;
drop index if exists ix_hostclass_stage_stage;
alter table manifest drop constraint if exists fk_manifest_environment_id;
drop index if exists ix_manifest_environment_id;
alter table manifest_package_version drop constraint if exists fk_manifest_package_version_manifest;
drop index if exists ix_manifest_package_version_manifest;
alter table manifest_package_version drop constraint if exists fk_manifest_package_version_package_version;
drop index if exists ix_manifest_package_version_package_version;
alter table manifest_history drop constraint if exists fk_manifest_history_manifest_id;
drop index if exists ix_manifest_history_manifest_id;
alter table manifest_history drop constraint if exists fk_manifest_history_stage_id;
drop index if exists ix_manifest_history_stage_id;
alter table package_version drop constraint if exists fk_package_version_pkg_id;
drop index if exists ix_package_version_pkg_id;
alter table stage drop constraint if exists fk_stage_environment_id;
drop index if exists ix_stage_environment_id;
alter table stage_hostclass drop constraint if exists fk_stage_hostclass_stage;
drop index if exists ix_stage_hostclass_stage;
alter table stage_hostclass drop constraint if exists fk_stage_hostclass_hostclass;
drop index if exists ix_stage_hostclass_hostclass;
alter table user_membership drop constraint if exists fk_user_membership_org_id;
drop index if exists ix_user_membership_org_id;
drop table if exists authentication;
drop table if exists bundle;
drop table if exists deployment;
drop table if exists deployment_log;
drop table if exists environment;
drop table if exists host;
drop table if exists host_deployment;
drop table if exists hostclass;
drop table if exists hostclass_stage;
drop table if exists inflight_deployment;
drop table if exists manifest;
drop table if exists manifest_package_version;
drop table if exists manifest_history;
drop table if exists owner;
drop table if exists package;
drop table if exists package_version;
drop table if exists stage;
drop table if exists stage_hostclass;
drop table if exists user_membership;