git.mcksp
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
create table if not exists users (
    id text not null primary key,
    username text not null unique,
    hash_pass text not null,
    created_at datetime not null
);

create table if not exists characters (
    id text not null primary key,
    user_id text not null,
    name text not null,
    description text not null,
    created_at datetime not null,
    foreign key(user_id) references user(id)
);
create unique index if not exists idx_characters_user_id_name on characters(user_id, name);

create table if not exists prompts (
    id text not null primary key,
    user_id text not null,
    prompt text not null,
    created_at datetime not null,
    foreign key(user_id) references user(id)
);

create table if not exists subscriptions (
    id text not null primary key,
    user_id text not null unique,
    stripe_customer_id text not null unique,
    active bool not null,
    created_at datetime not null,
    foreign key(user_id) references user(id)
);

create table if not exists stories (
    id text not null primary key,
    prompt_id text not null,
    user_id text not null,
    title text not null,
    summary text not null,
    story text not null,
    created_at datetime not null,
    foreign key(prompt_id) references prompts(id)
    foreign key(user_id) references user(id)
);

create table if not exists sessions (
    token text primary key,
    user_id text not null,
    expire_at datetime not null
);