create database fortern_life;

use fortern_life;

-- leaves_history table
create table leaves_history
(
    id          int auto_increment
        primary key,
    title       varchar(50) not null comment 'Title',
    description text        not null comment 'Description'
) comment 'Historical events';

-- leaves_history_item table
create table leaves_history_item
(
    id                 int auto_increment
        primary key,
    qq_no              bigint        not null comment 'QQ number',
    qq_group_no        int default 0 not null comment 'QQ group number',
    time_of_occurrence timestamp     not null comment 'Time of occurrence',
    info               varchar(1024) not null comment 'Description',
    history_id         int           not null comment 'History table id',
    index leaves_history_item_history_id_index (history_id),
    index leaves_history_item_qq_group_no_index (qq_group_no),
    index leaves_history_item_qq_no_index (qq_no),
    index leaves_history_item_time_of_occurrence_index(time_of_occurrence),
    constraint leaves_history_item_leaves_history_id_fk
        foreign key (history_id) references leaves_history (id)
            on update cascade
);
