summaryrefslogtreecommitdiff
path: root/src/invidious/database/migrations/0005_create_session_ids_table.cr
blob: 13c2228d1a30c2298b8f5e43aa145e5175fd4a9b (plain)
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
module Invidious::Database::Migrations
  class CreateSessionIdsTable < Migration
    version 5

    def up(conn : DB::Connection)
      conn.exec <<-SQL
      CREATE TABLE IF NOT EXISTS public.session_ids
      (
        id text NOT NULL,
        email text,
        issued timestamp with time zone,
        CONSTRAINT session_ids_pkey PRIMARY KEY (id)
      );
      SQL

      conn.exec <<-SQL
      GRANT ALL ON TABLE public.session_ids TO current_user;
      SQL

      conn.exec <<-SQL
      CREATE INDEX IF NOT EXISTS session_ids_id_idx
        ON public.session_ids
        USING btree
        (id COLLATE pg_catalog."default");
      SQL
    end
  end
end