# --- Created by Ebean DDL
# To stop Ebean DDL generation, remove this comment and start using Evolutions

# --- !Ups

create table company (
  id                            bigint auto_increment not null,
  name                          varchar(255),
  constraint pk_company primary key (id)
);

create table computer (
  id                            bigint auto_increment not null,
  owner_id                      bigint not null,
  name                          varchar(255),
  introduced                    timestamp,
  discontinued                  timestamp,
  company_id                    bigint,
  constraint pk_computer primary key (id)
);

create table owner (
  id                            bigint auto_increment not null,
  name                          varchar(255),
  constraint pk_owner primary key (id)
);

alter table computer add constraint fk_computer_owner_id foreign key (owner_id) references owner (id) on delete restrict on update restrict;
create index ix_computer_owner_id on computer (owner_id);

alter table computer add constraint fk_computer_company_id foreign key (company_id) references company (id) on delete restrict on update restrict;
create index ix_computer_company_id on computer (company_id);


# --- !Downs

alter table computer drop constraint if exists fk_computer_owner_id;
drop index if exists ix_computer_owner_id;

alter table computer drop constraint if exists fk_computer_company_id;
drop index if exists ix_computer_company_id;

drop table if exists company;

drop table if exists computer;

drop table if exists owner;

