summaryrefslogtreecommitdiff
path: root/src/invidious/database/migrations/0002_create_videos_table.cr
blob: c2ac84f8ff731c9530590b52aff9fa6b1670946b (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 CreateVideosTable < Migration
    version 2

    def up(conn : DB::Connection)
      conn.exec <<-SQL
      CREATE UNLOGGED TABLE IF NOT EXISTS public.videos
      (
        id text NOT NULL,
        info text,
        updated timestamp with time zone,
        CONSTRAINT videos_pkey PRIMARY KEY (id)
      );
      SQL

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

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