create table activation (
id bigint not null,
createdAt datetime(6) not null,
source varchar(255) not null,
updatedAt datetime(6),
userUUID varchar(255) not null,
bookId bigint,
primary key (id)
) engine=InnoDB;
create table activation_qr_code (
id bigint not null,
createdAt datetime(6) not null,
enabled bit not null,
lot varchar(255) not null,
qrCode longblob not null,
serialNumber varchar(255) not null,
updatedAt datetime(6),
vendor varchar(255) not null,
activationId bigint,
bookId bigint not null,
primary key (id)
) engine=InnoDB;
create table apk (
id bigint not null,
active bit not null,
apkType varchar(255) not null,
createdAt datetime(6) not null,
filedata longblob,
filename varchar(255),
sha256 varchar(255),
updatedAt datetime(6),
version integer not null,
primary key (id)
) engine=InnoDB;
create table auth_token (
id bigint not null,
primary key (id)
) engine=InnoDB;
create table book (
id bigint not null,
createdAt datetime(6) not null,
imagePreview longblob,
name varchar(255) not null,
orderInLibrary integer not null,
shopText TEXT not null,
updatedAt datetime(6),
woocommerceId bigint not null,
primary key (id)
) engine=InnoDB;
create table book_version (
id bigint not null,
active bit not null,
createdAt datetime(6) not null,
filedata longblob,
filename varchar(255),
sha256 varchar(255),
updatedAt datetime(6),
version integer not null,
bookId bigint,
primary key (id)
) engine=InnoDB;
create table hibernate_sequence (
next_val bigint
) engine=InnoDB;
insert into hibernate_sequence values ( 1 );
create table user_sessions (
id bigint not null auto_increment,
created_at datetime(6) not null,
token varchar(255) not null,
user_id varchar(255) not null,
primary key (id)
) engine=InnoDB;
create index idx_activation_book on activation (bookId);
alter table activation
add constraint UKa5fgkldlh0lk2ba18sqgpl3mh unique (userUUID, bookId);
create index idx_serialNumber on activation_qr_code (serialNumber);
alter table activation_qr_code
add constraint UK_eimanpw6o2aydwjmuwp38wp9j unique (serialNumber);
alter table apk
add constraint UKhntxbj8scpl71xr712q918s5w unique (sha256);
alter table apk
add constraint UKb9xg97iocnls0wwfuf5yjb0rs unique (apkType, version);
alter table book
add constraint UKwugryet8mf6oi28n00x2eoc4 unique (name);
alter table book
add constraint UKoaf20qi7twgfrip8ug61gecvi unique (woocommerceId);
create index idx_bookversion_book on book_version (bookId);
alter table book_version
add constraint UK4umnxsox8ovuc6il9c9ldwa2a unique (sha256);
alter table book_version
add constraint UK1yph5yprxj3b4vkocxwchifx3 unique (bookId, version);
alter table activation
add constraint FKihyqf0jocokir83wbwcjo3l15
foreign key (bookId)
references book (id);
alter table activation_qr_code
add constraint FKfs3py7fgkaq14gjmok8msf2s
foreign key (activationId)
references activation (id);
alter table activation_qr_code
add constraint FKo6kx1tdfgmiies1g1jqfornek
foreign key (bookId)
references book (id);
alter table book_version
add constraint FK97jhk4x2nfjtuduk2t1g5u7at
foreign key (bookId)
references book (id);
|