Jelajahi Sumber

go api 用的数据库迁移文件

visuddhinanda 4 tahun lalu
induk
melakukan
612729a06b
72 mengubah file dengan 990 tambahan dan 0 penghapusan
  1. 12 0
      db/go/20210709125349-new-courses/down.sql
  2. 44 0
      db/go/20210709125349-new-courses/up.sql
  3. 10 0
      db/go/20210715131154-create-articles/down.sql
  4. 34 0
      db/go/20210715131154-create-articles/up.sql
  5. 9 0
      db/go/20210716010532-create-collections/down.sql
  6. 31 0
      db/go/20210716010532-create-collections/up.sql
  7. 5 0
      db/go/20210716130715-collection-article_list/down.sql
  8. 8 0
      db/go/20210716130715-collection-article_list/up.sql
  9. 8 0
      db/go/20210814142535-create-groups/down.sql
  10. 27 0
      db/go/20210814142535-create-groups/up.sql
  11. 5 0
      db/go/20210815081726-create-groups_users/down.sql
  12. 11 0
      db/go/20210815081726-create-groups_users/up.sql
  13. 9 0
      db/go/20210815083122-create-channel/down.sql
  14. 28 0
      db/go/20210815083122-create-channel/up.sql
  15. 7 0
      db/go/20210815083954-create-dictionaries/down.sql
  16. 27 0
      db/go/20210815083954-create-dictionaries/up.sql
  17. 5 0
      db/go/20210815085816-create-dictionaries_users/down.sql
  18. 11 0
      db/go/20210815085816-create-dictionaries_users/up.sql
  19. 6 0
      db/go/20210815090502-create-ref_dicts/down.sql
  20. 17 0
      db/go/20210815090502-create-ref_dicts/up.sql
  21. 3 0
      db/go/20210815091124-create-ref_dict_names/down.sql
  22. 12 0
      db/go/20210815091124-create-ref_dict_names/up.sql
  23. 9 0
      db/go/20210815091717-create-terms/down.sql
  24. 29 0
      db/go/20210815091717-create-terms/up.sql
  25. 5 0
      db/go/20210815093008-create-active_logs/down.sql
  26. 12 0
      db/go/20210815093008-create-active_logs/up.sql
  27. 3 0
      db/go/20210815094313-create-active_time_frames/down.sql
  28. 11 0
      db/go/20210815094313-create-active_time_frames/up.sql
  29. 3 0
      db/go/20210815094947-create-active_day_frames/down.sql
  30. 14 0
      db/go/20210815094947-create-active_day_frames/up.sql
  31. 7 0
      db/go/20210815111104-create-sentences/down.sql
  32. 34 0
      db/go/20210815111104-create-sentences/up.sql
  33. 3 0
      db/go/20210815124410-create-sentences_historaies/down.sql
  34. 16 0
      db/go/20210815124410-create-sentences_historaies/up.sql
  35. 13 0
      db/go/20210815125606-create-share_resources/down.sql
  36. 25 0
      db/go/20210815125606-create-share_resources/up.sql
  37. 10 0
      db/go/20210816150747-create-likes/down.sql
  38. 21 0
      db/go/20210816150747-create-likes/up.sql
  39. 9 0
      db/go/20210816152357-create-books/down.sql
  40. 25 0
      db/go/20210816152357-create-books/up.sql
  41. 6 0
      db/go/20210817121707-create-pali_texts/down.sql
  42. 30 0
      db/go/20210817121707-create-pali_texts/up.sql
  43. 6 0
      db/go/20210817123420-create-wbw_templates/down.sql
  44. 20 0
      db/go/20210817123420-create-wbw_templates/up.sql
  45. 6 0
      db/go/20210817125039-create-nissaya_book_maps/down.sql
  46. 17 0
      db/go/20210817125039-create-nissaya_book_maps/up.sql
  47. 5 0
      db/go/20210817125640-create-nissaya_page_maps/down.sql
  48. 16 0
      db/go/20210817125640-create-nissaya_page_maps/up.sql
  49. 6 0
      db/go/20210817130051-create-multi_edition_page_numbers/down.sql
  50. 16 0
      db/go/20210817130051-create-multi_edition_page_numbers/up.sql
  51. 6 0
      db/go/20210817130831-create-cs_para_numbers/down.sql
  52. 16 0
      db/go/20210817130831-create-cs_para_numbers/up.sql
  53. 7 0
      db/go/20210817132110-create-pali_word_indeces/down.sql
  54. 19 0
      db/go/20210817132110-create-pali_word_indeces/up.sql
  55. 6 0
      db/go/20210817133001-create-pali_words/down.sql
  56. 16 0
      db/go/20210817133001-create-pali_words/up.sql
  57. 4 0
      db/go/20210817134935-create-word_in_book_indeces/down.sql
  58. 11 0
      db/go/20210817134935-create-word_in_book_indeces/up.sql
  59. 5 0
      db/go/20210817135430-create-bolds/down.sql
  60. 14 0
      db/go/20210817135430-create-bolds/up.sql
  61. 8 0
      db/go/20210817140053-create-sub_books/down.sql
  62. 17 0
      db/go/20210817140053-create-sub_books/up.sql
  63. 5 0
      db/go/20210817140800-create-wbws/down.sql
  64. 34 0
      db/go/20210817140800-create-wbws/up.sql
  65. 4 0
      db/go/20210817141841-create-wbws_indeces/down.sql
  66. 19 0
      db/go/20210817141841-create-wbws_indeces/up.sql
  67. 4 0
      db/go/20210818145019-create-wbws_lists/down.sql
  68. 27 0
      db/go/20210818145019-create-wbws_lists/up.sql
  69. 7 0
      db/go/20210823022504-create-comments/down.sql
  70. 27 0
      db/go/20210823022504-create-comments/up.sql
  71. 6 0
      db/go/20210827095853-create-studio/down.sql
  72. 22 0
      db/go/20210827095853-create-studio/up.sql

+ 12 - 0
db/go/20210709125349-new-courses/down.sql

@@ -0,0 +1,12 @@
+-- This file should undo anything in `up.sql`
+DROP INDEX  IF EXISTS  courses_title ;
+DROP INDEX  IF EXISTS  courses_status ;
+DROP INDEX  IF EXISTS  courses_lang ;
+DROP INDEX  IF EXISTS  courses_lang_status ;
+DROP INDEX  IF EXISTS  courses_uid ;
+
+DROP TABLE courses ;
+
+DROP TYPE TStatus ;
+DROP TYPE TContentType ;
+

+ 44 - 0
db/go/20210709125349-new-courses/up.sql

@@ -0,0 +1,44 @@
+-- Your SQL goes here
+CREATE TYPE TStatus AS ENUM ('disable','private','public');
+CREATE TYPE TContentType AS ENUM ('text','markdown','html');
+
+CREATE TABLE courses
+( 
+    id SERIAL PRIMARY KEY, 
+    uid VARCHAR(36)  NOT NULL,
+    parent_id INTEGER , 
+    pr_parent_id INTEGER ,
+    
+    cover VARCHAR(255), 
+    title VARCHAR(255) NOT NULL, 
+    subtitle VARCHAR(255),
+    summary VARCHAR(1024),
+
+    teacher_id INTEGER, 
+    lang      VARCHAR (16) NOT NULL DEFAULT('en'),
+    speech_lang VARCHAR (16) NOT NULL DEFAULT('en'),
+    lesson_num INTEGER NOT NULL DEFAULT(0), 
+
+    start_at TIMESTAMP ,
+    end_at TIMESTAMP ,
+    
+
+    content TEXT , 
+    content_type TContentType NOT NULL DEFAULT('markdown'), 
+    
+    status TStatus  NOT NULL DEFAULT('private'), 
+    editor_id INTEGER NOT NULL, 
+    studio_id INTEGER NOT NULL, 
+    owner_id INTEGER NOT NULL, 
+
+    version     INTEGER NOT NULL DEFAULT (1),
+    deleted_at TIMESTAMP ,
+
+    created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+    updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+CREATE INDEX courses_title ON courses (title);
+CREATE INDEX courses_lang ON courses (lang);
+CREATE INDEX courses_status ON courses (status);
+CREATE INDEX courses_lang_status ON courses (lang,status);
+CREATE UNIQUE INDEX courses_uid ON courses (uid);

+ 10 - 0
db/go/20210715131154-create-articles/down.sql

@@ -0,0 +1,10 @@
+-- This file should undo anything in `up.sql`
+
+DROP INDEX IF EXISTS articles_title ;
+DROP INDEX IF EXISTS articles_status ;
+DROP INDEX IF EXISTS articles_lang ;
+DROP INDEX IF EXISTS articles_lang_status;
+DROP INDEX IF EXISTS articles_uid ;
+
+DROP TABLE articles;
+

+ 34 - 0
db/go/20210715131154-create-articles/up.sql

@@ -0,0 +1,34 @@
+-- Your SQL goes here
+
+CREATE TABLE articles (
+    id           SERIAL PRIMARY KEY,
+    uid          VARCHAR (36) ,
+    parent_id    INTEGER ,
+    pr_parent_id INTEGER ,
+
+    title        VARCHAR (255) NOT NULL,
+    subtitle     VARCHAR (255),
+    summary      VARCHAR (1024),
+
+    content      TEXT,
+    content_type TContentType NOT NULL DEFAULT('markdown'), 
+    
+    lang      VARCHAR (16) NOT NULL DEFAULT('en'),
+    setting      JSON NOT NULL DEFAULT('{}'), 
+
+    status TStatus  NOT NULL DEFAULT('private'), 
+    owner_id INTEGER NOT NULL, 
+
+	version     INTEGER NOT NULL DEFAULT (1),
+    deleted_at  TIMESTAMP,
+
+    created_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+    updated_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+CREATE INDEX articles_title ON courses (title);
+CREATE INDEX articles_status ON courses (status);
+CREATE INDEX articles_lang ON courses (lang);
+CREATE INDEX articles_lang_status ON articles (lang,status);
+
+CREATE UNIQUE INDEX articles_uid ON courses (uid);

+ 9 - 0
db/go/20210716010532-create-collections/down.sql

@@ -0,0 +1,9 @@
+-- This file should undo anything in `up.sql`
+
+DROP INDEX IF EXISTS collections_title;
+DROP INDEX IF EXISTS collections_lang ;
+DROP INDEX IF EXISTS collections_status ;
+DROP INDEX IF EXISTS collections_lang_status;
+DROP INDEX IF EXISTS collections_uid;
+
+DROP TABLE collections;

+ 31 - 0
db/go/20210716010532-create-collections/up.sql

@@ -0,0 +1,31 @@
+-- Your SQL goes here
+
+CREATE TABLE collections (
+    id SERIAL PRIMARY KEY,
+    uid         VARCHAR (36) ,
+    parent_id   INTEGER NOT NULL,
+    pr_parent_id INTEGER NOT NULL,
+
+    title        VARCHAR (255) NOT NULL,
+    subtitle     VARCHAR (255),
+    summary      VARCHAR (1024),
+
+    article_list JSON NOT NULL DEFAULT('[]'), 
+    
+    lang      VARCHAR (16),
+    setting      JSON NOT NULL DEFAULT('{}'), 
+
+    status TStatus  NOT NULL DEFAULT('private'), 
+    owner_id INTEGER NOT NULL, 
+
+	version     INTEGER NOT NULL DEFAULT (1),
+    deleted_at  TIMESTAMP,
+    created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+    updated_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+CREATE INDEX collections_title ON courses (title);
+CREATE INDEX collections_lang ON courses (lang);
+CREATE INDEX collections_status ON courses (status);
+CREATE INDEX collections_lang_status ON courses (lang,status);
+CREATE UNIQUE INDEX collections_uid ON courses (uid);

+ 5 - 0
db/go/20210716130715-collection-article_list/down.sql

@@ -0,0 +1,5 @@
+-- This file should undo anything in `up.sql`
+
+DROP INDEX IF EXISTS article_lists_article_collection;
+
+DROP TABLE article_lists;

+ 8 - 0
db/go/20210716130715-collection-article_list/up.sql

@@ -0,0 +1,8 @@
+-- article 关联表
+CREATE TABLE article_lists (
+    id SERIAL PRIMARY KEY,
+    collection_id    INTEGER NOT NULL ,
+    article_id    INTEGER  NOT NULL ,
+    created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+CREATE UNIQUE INDEX article_lists_article_collection ON article_lists (collection_id,article_id);

+ 8 - 0
db/go/20210814142535-create-groups/down.sql

@@ -0,0 +1,8 @@
+-- This file should undo anything in `up.sql`
+
+DROP INDEX IF EXISTS groups_name;
+DROP INDEX IF EXISTS groups_status;
+
+DROP TABLE groups;
+
+DROP INDEX IF EXISTS groups_uid;

+ 27 - 0
db/go/20210814142535-create-groups/up.sql

@@ -0,0 +1,27 @@
+-- Your SQL goes here
+
+CREATE TABLE groups (
+    id           SERIAL PRIMARY KEY,
+    uid          VARCHAR (36) ,
+
+    name         VARCHAR (255) NOT NULL,
+
+    description      TEXT,
+    description_type TContentType NOT NULL DEFAULT('markdown'), 
+    
+    setting      JSON NOT NULL DEFAULT('{}'), 
+
+    status       TStatus  NOT NULL DEFAULT('private'), 
+    owner_id     INTEGER NOT NULL, 
+
+	version     INTEGER NOT NULL DEFAULT (1),
+    deleted_at  TIMESTAMP,
+
+    created_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+    updated_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+CREATE INDEX groups_name ON groups (name);
+CREATE INDEX groups_status ON groups (status);
+
+CREATE UNIQUE INDEX groups_uid ON groups (uid);

+ 5 - 0
db/go/20210815081726-create-groups_users/down.sql

@@ -0,0 +1,5 @@
+-- This file should undo anything in `up.sql`
+
+DROP INDEX IF EXISTS group_user_id;
+
+DROP TABLE groups_users;

+ 11 - 0
db/go/20210815081726-create-groups_users/up.sql

@@ -0,0 +1,11 @@
+-- Your SQL goes here
+
+CREATE TABLE groups_users (
+    id          SERIAL PRIMARY KEY,
+    group_id    INTEGER NOT NULL,
+    user_id     INTEGER NOT NULL, 
+
+    created_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+CREATE UNIQUE INDEX group_user_id ON groups_users (group_id,user_id);

+ 9 - 0
db/go/20210815083122-create-channel/down.sql

@@ -0,0 +1,9 @@
+-- This file should undo anything in `up.sql`
+
+DROP INDEX IF EXISTS channels_title ;
+DROP INDEX IF EXISTS channels_status ;
+DROP INDEX IF EXISTS channels_lang ;
+DROP INDEX IF EXISTS channels_lang_status;
+DROP INDEX IF EXISTS channels_uid ;
+
+DROP TABLE channels;

+ 28 - 0
db/go/20210815083122-create-channel/up.sql

@@ -0,0 +1,28 @@
+-- Your SQL goes here
+
+CREATE TABLE channels (
+    id           SERIAL PRIMARY KEY,
+    uid          VARCHAR (36) ,
+
+    title        VARCHAR (255) NOT NULL,
+    summary      VARCHAR (1024),
+
+    lang      VARCHAR (16) NOT NULL DEFAULT('en'),
+    setting      JSON NOT NULL DEFAULT('{}'), 
+
+    status TStatus  NOT NULL DEFAULT('private'), 
+    owner_id INTEGER NOT NULL, 
+
+	version     INTEGER NOT NULL DEFAULT (1),
+    deleted_at  TIMESTAMP,
+
+    created_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+    updated_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+CREATE INDEX channels_title ON channels (title);
+CREATE INDEX channels_status ON channels (status);
+CREATE INDEX channels_lang ON channels (lang);
+CREATE INDEX channels_lang_status ON channels (lang,status);
+
+CREATE UNIQUE INDEX channels_uid ON channels (uid);

+ 7 - 0
db/go/20210815083954-create-dictionaries/down.sql

@@ -0,0 +1,7 @@
+-- This file should undo anything in `up.sql`
+
+DROP INDEX IF EXISTS dictionaries_word;
+DROP INDEX IF EXISTS dictionaries_base;
+DROP INDEX IF EXISTS dictionaries_lang;
+
+DROP TABLE dictionaries;

+ 27 - 0
db/go/20210815083954-create-dictionaries/up.sql

@@ -0,0 +1,27 @@
+-- Your SQL goes here
+
+CREATE TABLE dictionaries (
+    id           SERIAL PRIMARY KEY,
+
+    word        VARCHAR (512) NOT NULL,
+    type        VARCHAR (512) NOT NULL DEFAULT(''),
+    grammar        VARCHAR (512) NOT NULL DEFAULT(''),
+    base        VARCHAR (512) NOT NULL DEFAULT(''),
+    meaning        VARCHAR (512) NOT NULL DEFAULT(''),
+    note        TEXT NOT NULL DEFAULT(''),
+    factors        VARCHAR (512) NOT NULL DEFAULT(''),
+    factors_meaning        VARCHAR (512) NOT NULL DEFAULT(''),
+
+    lang      VARCHAR (16) NOT NULL DEFAULT('en'),
+    sourse        VARCHAR (512) NOT NULL DEFAULT(''),
+    owner_id INTEGER NOT NULL, 
+
+	version     INTEGER NOT NULL DEFAULT (1),
+
+    created_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+    updated_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+CREATE INDEX dictionaries_word ON dictionaries (word);
+CREATE INDEX dictionaries_base ON dictionaries (base);
+CREATE INDEX dictionaries_lang ON dictionaries (word,lang);

+ 5 - 0
db/go/20210815085816-create-dictionaries_users/down.sql

@@ -0,0 +1,5 @@
+-- This file should undo anything in `up.sql`
+
+DROP INDEX IF EXISTS dictionaries_user_id;
+
+DROP TABLE dictionaries_users;

+ 11 - 0
db/go/20210815085816-create-dictionaries_users/up.sql

@@ -0,0 +1,11 @@
+-- Your SQL goes here
+
+CREATE TABLE dictionaries_users (
+    id          SERIAL PRIMARY KEY,
+    dictionaries_id    INTEGER NOT NULL,
+    user_id     INTEGER NOT NULL, 
+
+    created_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+CREATE UNIQUE INDEX dictionaries_user_id ON dictionaries_users (dictionaries_id,user_id);

+ 6 - 0
db/go/20210815090502-create-ref_dicts/down.sql

@@ -0,0 +1,6 @@
+-- This file should undo anything in `up.sql`
+
+DROP INDEX IF EXISTS ref_dicts_word ;
+DROP INDEX IF EXISTS ref_dicts_word_en;
+
+DROP TABLE ref_dicts;

+ 17 - 0
db/go/20210815090502-create-ref_dicts/up.sql

@@ -0,0 +1,17 @@
+-- Your SQL goes here
+
+CREATE TABLE ref_dicts (
+    id           SERIAL PRIMARY KEY,
+
+    word        VARCHAR (512) NOT NULL,
+    word_en        VARCHAR (512) NOT NULL DEFAULT(''),
+    meaning        VARCHAR (512) NOT NULL DEFAULT(''),
+
+    lang      VARCHAR (16) NOT NULL DEFAULT('en'),
+	ref_dict_name_id     INTEGER NOT NULL DEFAULT (1),
+
+    created_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+CREATE INDEX ref_dicts_word ON ref_dicts (word);
+CREATE INDEX ref_dicts_word_en ON ref_dicts (word_en);

+ 3 - 0
db/go/20210815091124-create-ref_dict_names/down.sql

@@ -0,0 +1,3 @@
+-- This file should undo anything in `up.sql`
+
+DROP TABLE ref_dict_names;

+ 12 - 0
db/go/20210815091124-create-ref_dict_names/up.sql

@@ -0,0 +1,12 @@
+-- Your SQL goes here
+
+CREATE TABLE ref_dict_names (
+    id           SERIAL PRIMARY KEY,
+
+    name        VARCHAR (512) NOT NULL,
+    short_name        VARCHAR (32) NOT NULL DEFAULT(''),
+
+    lang      VARCHAR (16) NOT NULL DEFAULT('en'),
+
+    created_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);

+ 9 - 0
db/go/20210815091717-create-terms/down.sql

@@ -0,0 +1,9 @@
+-- This file should undo anything in `up.sql`
+
+DROP INDEX IF EXISTS terms_word ;
+DROP INDEX IF EXISTS terms_worden;
+DROP INDEX IF EXISTS terms_lang;
+DROP INDEX IF EXISTS terms_channel_id;
+
+DROP TABLE terms;
+

+ 29 - 0
db/go/20210815091717-create-terms/up.sql

@@ -0,0 +1,29 @@
+-- Your SQL goes here
+
+CREATE TABLE terms (
+    id           SERIAL PRIMARY KEY,
+	pr_parent_id    INTEGER,
+
+    word        VARCHAR (512) NOT NULL,
+    word_en        VARCHAR (512) NOT NULL ,
+    tag        VARCHAR (512) NOT NULL DEFAULT(''),
+    channel_id        INTEGER,
+    meaning        VARCHAR (512) NOT NULL DEFAULT(''),
+    meaning2        VARCHAR (512) NOT NULL DEFAULT(''),
+    note        TEXT NOT NULL DEFAULT(''),
+
+    lang      VARCHAR (16) NOT NULL DEFAULT('en'),
+    sourse        VARCHAR (512) NOT NULL DEFAULT(''),
+	confidence     INTEGER NOT NULL DEFAULT (10),
+
+    owner_id INTEGER NOT NULL, 
+	version     INTEGER NOT NULL DEFAULT (1),
+
+    created_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+    updated_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+CREATE INDEX terms_word ON terms (word);
+CREATE INDEX terms_worden ON terms (word_en);
+CREATE INDEX terms_lang ON terms (word,lang);
+CREATE INDEX terms_channel_id ON terms (word,channel_id);

+ 5 - 0
db/go/20210815093008-create-active_logs/down.sql

@@ -0,0 +1,5 @@
+-- This file should undo anything in `up.sql`
+
+DROP TYPE TActiveType ;
+
+DROP TABLE active_logs;

+ 12 - 0
db/go/20210815093008-create-active_logs/up.sql

@@ -0,0 +1,12 @@
+-- Your SQL goes here
+CREATE TYPE TActiveType AS ENUM ('dict','wbw','term','sentence','lookup','course','article','collection');
+
+CREATE TABLE active_logs (
+    id          SERIAL PRIMARY KEY,
+    user_id     INTEGER NOT NULL,
+    active_type TActiveType  NOT NULL, 
+    content     TEXT,
+    timezone    VARCHAR (32) NOT NULL,
+
+    created_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);

+ 3 - 0
db/go/20210815094313-create-active_time_frames/down.sql

@@ -0,0 +1,3 @@
+-- This file should undo anything in `up.sql`
+
+DROP TABLE active_time_frames;

+ 11 - 0
db/go/20210815094313-create-active_time_frames/up.sql

@@ -0,0 +1,11 @@
+-- Your SQL goes here
+
+CREATE TABLE active_time_frames (
+    id          SERIAL PRIMARY KEY,
+    user_id     INTEGER NOT NULL,
+    hit         INTEGER NOT NULL DEFAULT(1),
+    timezone    VARCHAR (32) NOT NULL,
+
+    updated_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+    created_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);

+ 3 - 0
db/go/20210815094947-create-active_day_frames/down.sql

@@ -0,0 +1,3 @@
+-- This file should undo anything in `up.sql`
+
+DROP TABLE active_day_frames;

+ 14 - 0
db/go/20210815094947-create-active_day_frames/up.sql

@@ -0,0 +1,14 @@
+-- Your SQL goes here
+
+CREATE TABLE active_day_frames (
+    id          SERIAL PRIMARY KEY,
+    user_id     INTEGER NOT NULL,
+    date        TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+
+    duration    INTEGER NOT NULL DEFAULT(1),
+    hit         INTEGER NOT NULL DEFAULT(1),
+
+    updated_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+    created_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+

+ 7 - 0
db/go/20210815111104-create-sentences/down.sql

@@ -0,0 +1,7 @@
+-- This file should undo anything in `up.sql`
+DROP INDEX IF EXISTS sentences_unique ;
+
+DROP TABLE sentences;
+
+
+DROP TYPE TSentenceType

+ 34 - 0
db/go/20210815111104-create-sentences/up.sql

@@ -0,0 +1,34 @@
+-- Your SQL goes here
+CREATE TYPE TSentenceType AS ENUM ('origin','translation','relation');
+
+CREATE TABLE sentences (
+    id           SERIAL PRIMARY KEY,
+    is_pr        BOOL  DEFAULT(FALSE),
+    block_id     INTEGER ,
+
+    channel_id   INTEGER ,
+    book_id      INTEGER  NOT NULL,
+    paragraph    INTEGER  NOT NULL,
+    word_start        INTEGER  NOT NULL,
+    word_end        INTEGER  NOT NULL,
+
+    content      TEXT,
+    content_type TContentType NOT NULL DEFAULT('markdown'), 
+    
+    type         TSentenceType NOT NULL DEFAULT('translation'), 
+    lang         VARCHAR (16) NOT NULL DEFAULT('en'),
+    status TStatus  NOT NULL DEFAULT('private'), 
+
+    editor_id INTEGER  NOT NULL,
+    owner_id INTEGER  NOT NULL,
+
+	version     INTEGER NOT NULL DEFAULT (1),
+    deleted_at  TIMESTAMP,
+
+    created_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+    updated_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+
+CREATE INDEX sentences_unique ON sentences ("channel_id","book_id","paragraph","word_start","word_end");
+

+ 3 - 0
db/go/20210815124410-create-sentences_historaies/down.sql

@@ -0,0 +1,3 @@
+-- This file should undo anything in `up.sql`
+
+DROP TABLE sentences_historays;

+ 16 - 0
db/go/20210815124410-create-sentences_historaies/up.sql

@@ -0,0 +1,16 @@
+-- Your SQL goes here
+
+CREATE TABLE sentences_historays (
+    id           SERIAL PRIMARY KEY,
+    sentence_id INTEGER ,
+
+    content      TEXT,
+    content_type TContentType NOT NULL DEFAULT('markdown'), 
+    
+    editor_id INTEGER  NOT NULL,
+
+    created_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+
+

+ 13 - 0
db/go/20210815125606-create-share_resources/down.sql

@@ -0,0 +1,13 @@
+-- This file should undo anything in `up.sql`
+
+
+DROP INDEX authorizations_unique;
+
+DROP TABLE authorizations ;
+
+DROP TYPE TResourceType ;
+DROP TYPE TUserType ;
+DROP TYPE TRightType ;
+
+
+

+ 25 - 0
db/go/20210815125606-create-share_resources/up.sql

@@ -0,0 +1,25 @@
+-- Your SQL goes here
+CREATE TYPE TResourceType AS ENUM ('channel','article','collection','sentence','wbw');
+CREATE TYPE TUserType AS ENUM ('user','group');
+CREATE TYPE TRightType AS ENUM ('read','write','admin','owner');
+
+CREATE TABLE authorizations (
+    id              SERIAL PRIMARY KEY,
+    resource_id     INTEGER  NOT NULL,
+    resource_type   TResourceType NOT NULL,
+
+    user_id   INTEGER  NOT NULL,
+    user_type TUserType NOT NULL , 
+    
+    res_right       TRightType  NOT NULL,
+    owner_id        INTEGER  NOT NULL,
+    expired_at      TIMESTAMP,
+    accepted_at     TIMESTAMP,
+    updated_at      TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+    created_at      TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+CREATE UNIQUE INDEX authorizations_unique ON authorizations (resource_id,resource_type,user_id,user_type);
+
+
+

+ 10 - 0
db/go/20210816150747-create-likes/down.sql

@@ -0,0 +1,10 @@
+-- This file should undo anything in `up.sql`
+
+
+DROP INDEX likes_unique ;
+DROP TABLE likes ;
+DROP TYPE  TLikeType ;
+
+
+
+

+ 21 - 0
db/go/20210816150747-create-likes/up.sql

@@ -0,0 +1,21 @@
+-- Your SQL goes here
+CREATE TYPE TLikeType AS ENUM ('like','favorite','watch');
+
+CREATE TABLE likes (
+    id           SERIAL PRIMARY KEY,
+    like_type    TLikeType  NOT NULL,
+
+    resource_id   INTEGER  NOT NULL,
+    resource_type  TResourceType NOT NULL,
+
+    user_id   INTEGER  NOT NULL,
+    
+    emoji      VARCHAR(8),
+
+    created_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+CREATE UNIQUE INDEX likes_unique ON likes (like_type,resource_id,resource_type,user_id);
+
+
+

+ 9 - 0
db/go/20210816152357-create-books/down.sql

@@ -0,0 +1,9 @@
+-- This file should undo anything in `up.sql`
+
+DROP INDEX  books_title ;
+DROP INDEX  books_status ;
+DROP INDEX  books_lang ;
+DROP INDEX  books_lang_status;
+
+DROP TABLE books;
+

+ 25 - 0
db/go/20210816152357-create-books/up.sql

@@ -0,0 +1,25 @@
+-- Your SQL goes here
+
+CREATE TABLE books (
+    id           SERIAL PRIMARY KEY,
+
+    title        VARCHAR (255) NOT NULL,
+    summary      VARCHAR (1024),
+    lang      VARCHAR (16) NOT NULL DEFAULT('en'),
+
+    channel_id INTEGER NOT NULL, 
+
+    status TStatus  NOT NULL DEFAULT('private'), 
+    owner_id INTEGER NOT NULL, 
+
+	version     INTEGER NOT NULL DEFAULT (1),
+    deleted_at  TIMESTAMP,
+
+    created_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+    updated_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+CREATE INDEX books_title ON books (title);
+CREATE INDEX books_status ON books (status);
+CREATE INDEX books_lang ON books (lang);
+CREATE INDEX books_lang_status ON books (lang,status);

+ 6 - 0
db/go/20210817121707-create-pali_texts/down.sql

@@ -0,0 +1,6 @@
+-- This file should undo anything in `up.sql`
+
+DROP INDEX  pali_text ;
+
+DROP TABLE pali_texts;
+

+ 30 - 0
db/go/20210817121707-create-pali_texts/up.sql

@@ -0,0 +1,30 @@
+-- Your SQL goes here
+
+CREATE TABLE pali_texts (
+    id           SERIAL PRIMARY KEY,
+
+    book_id      INTEGER NOT NULL, 
+    paragraph    INTEGER NOT NULL, 
+    level        INTEGER NOT NULL, 
+
+    class        VARCHAR (32) NOT NULL,
+    toc          VARCHAR (255) NOT NULL,
+    text         TEXT,
+    html         TEXT,
+
+    str_length   INTEGER NOT NULL, 
+    chapter_len  INTEGER NOT NULL, 
+    next_chapter INTEGER NOT NULL, 
+    prev_chapter INTEGER NOT NULL, 
+    parent       INTEGER NOT NULL, 
+    chapter_strlen        INTEGER NOT NULL, 
+    path         JSON NOT NULL, 
+
+	version     INTEGER NOT NULL DEFAULT (1),
+
+    created_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+    updated_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+
+CREATE UNIQUE INDEX pali_text ON pali_texts (book_id,paragraph);

+ 6 - 0
db/go/20210817123420-create-wbw_templates/down.sql

@@ -0,0 +1,6 @@
+-- This file should undo anything in `up.sql`
+
+DROP INDEX  wbw_templates_unique ;
+
+DROP TABLE wbw_templates;
+

+ 20 - 0
db/go/20210817123420-create-wbw_templates/up.sql

@@ -0,0 +1,20 @@
+-- Your SQL goes here
+
+CREATE TABLE wbw_templates (
+    id           SERIAL PRIMARY KEY,
+
+    book_id      INTEGER NOT NULL, 
+    paragraph    INTEGER NOT NULL, 
+    word_sn        INTEGER NOT NULL, 
+
+    word        VARCHAR (512) NOT NULL,
+    real_word          VARCHAR (512) NOT NULL,
+    type          VARCHAR (32),
+    grammar          VARCHAR (32),
+    factors          VARCHAR (512),
+
+    created_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+
+CREATE UNIQUE INDEX wbw_templates_unique ON wbw_templates (book_id,paragraph,word_sn);

+ 6 - 0
db/go/20210817125039-create-nissaya_book_maps/down.sql

@@ -0,0 +1,6 @@
+-- This file should undo anything in `up.sql`
+
+DROP INDEX  nissaya_book_maps_nsy_book_id ;
+
+DROP TABLE nissaya_book_maps;
+

+ 17 - 0
db/go/20210817125039-create-nissaya_book_maps/up.sql

@@ -0,0 +1,17 @@
+-- Your SQL goes here
+
+CREATE TABLE nissaya_book_maps (
+    id           SERIAL PRIMARY KEY,
+
+    nsy_book_id     VARCHAR (64) NOT NULL, 
+    book_id    INTEGER NOT NULL, 
+    vol    INTEGER NOT NULL, 
+
+    title        VARCHAR (64) NOT NULL,
+    type          VARCHAR (16) NOT NULL,
+
+    created_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+
+CREATE INDEX nissaya_book_maps_nsy_book_id ON nissaya_book_maps (nsy_book_id);

+ 5 - 0
db/go/20210817125640-create-nissaya_page_maps/down.sql

@@ -0,0 +1,5 @@
+-- This file should undo anything in `up.sql`
+
+
+DROP TABLE nissaya_page_maps;
+

+ 16 - 0
db/go/20210817125640-create-nissaya_page_maps/up.sql

@@ -0,0 +1,16 @@
+-- Your SQL goes here
+
+CREATE TABLE nissaya_page_maps (
+    id           SERIAL PRIMARY KEY,
+
+    type     VARCHAR (8) NOT NULL, 
+    nsy_book_id    INTEGER NOT NULL, 
+    book_page_number    INTEGER NOT NULL, 
+
+    nsy_id        VARCHAR (8) NOT NULL,
+    nsy_page_number    INTEGER NOT NULL, 
+    nsy_name          VARCHAR (32) NOT NULL,
+
+    created_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+

+ 6 - 0
db/go/20210817130051-create-multi_edition_page_numbers/down.sql

@@ -0,0 +1,6 @@
+-- This file should undo anything in `up.sql`
+
+DROP INDEX  multi_edition_page_numbers_book_para ;
+
+DROP TABLE multi_edition_page_numbers;
+

+ 16 - 0
db/go/20210817130051-create-multi_edition_page_numbers/up.sql

@@ -0,0 +1,16 @@
+-- Your SQL goes here
+--不同版本页码
+CREATE TABLE multi_edition_page_numbers (
+    id           SERIAL PRIMARY KEY,
+
+    edition     VARCHAR (8) NOT NULL, 
+    book_id    INTEGER NOT NULL, 
+    paragraph    INTEGER NOT NULL, 
+    vol    INTEGER NOT NULL, 
+    page    INTEGER NOT NULL, 
+
+    created_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+
+CREATE INDEX multi_edition_page_numbers_book_para ON multi_edition_page_numbers (book_id,page);

+ 6 - 0
db/go/20210817130831-create-cs_para_numbers/down.sql

@@ -0,0 +1,6 @@
+-- This file should undo anything in `up.sql`
+
+DROP INDEX  cs_para_numbers_book ;
+
+DROP TABLE cs_para_numbers;
+

+ 16 - 0
db/go/20210817130831-create-cs_para_numbers/up.sql

@@ -0,0 +1,16 @@
+-- Your SQL goes here
+--不同版本页码
+CREATE TABLE cs_para_numbers (
+    id           SERIAL PRIMARY KEY,
+
+    book_id      INTEGER NOT NULL, 
+    paragraph    INTEGER NOT NULL, 
+    sub_book_id  INTEGER NOT NULL, 
+    cs_paragraph INTEGER NOT NULL, 
+    book_name    VARCHAR(8) NOT NULL, 
+
+    created_at   TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+
+CREATE INDEX cs_para_numbers_book ON cs_para_numbers (book_id,paragraph,cs_paragraph);

+ 7 - 0
db/go/20210817132110-create-pali_word_indeces/down.sql

@@ -0,0 +1,7 @@
+-- This file should undo anything in `up.sql`
+
+DROP INDEX  pali_word_indeces_word ;
+DROP INDEX  pali_word_indeces_word_en ;
+
+DROP TABLE pali_word_indexs;
+

+ 19 - 0
db/go/20210817132110-create-pali_word_indeces/up.sql

@@ -0,0 +1,19 @@
+-- Your SQL goes here
+-- 93 万词
+CREATE TABLE pali_word_indexs (
+    id           SERIAL PRIMARY KEY,
+    word    VARCHAR(8) NOT NULL, 
+    word_en    VARCHAR(8) NOT NULL, 
+
+    count      INTEGER NOT NULL, 
+    normal     INTEGER NOT NULL, 
+    bold       INTEGER NOT NULL, 
+    is_base    BOOL NOT NULL, 
+    str_len       INTEGER NOT NULL, 
+
+    created_at   TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+
+CREATE INDEX pali_word_indexs_word ON pali_word_indexs (word);
+CREATE INDEX pali_word_indexs_word_en ON pali_word_indexs (word_en);

+ 6 - 0
db/go/20210817133001-create-pali_words/down.sql

@@ -0,0 +1,6 @@
+-- This file should undo anything in `up.sql`
+
+DROP INDEX  pali_words_book_para ;
+
+DROP TABLE pali_words;
+

+ 16 - 0
db/go/20210817133001-create-pali_words/up.sql

@@ -0,0 +1,16 @@
+-- Your SQL goes here
+
+CREATE TABLE pali_words (
+    id           SERIAL PRIMARY KEY,
+
+    book_id      INTEGER NOT NULL, 
+    paragraph     INTEGER NOT NULL, 
+    pali_word_index_id       INTEGER NOT NULL, 
+    is_base    BOOL NOT NULL, 
+    weight       INTEGER NOT NULL, 
+
+    created_at   TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+
+CREATE INDEX pali_words_book_para ON pali_words (book_id,paragraph);

+ 4 - 0
db/go/20210817134935-create-word_in_book_indeces/down.sql

@@ -0,0 +1,4 @@
+-- This file should undo anything in `up.sql`
+
+DROP TABLE word_in_book_indexs;
+

+ 11 - 0
db/go/20210817134935-create-word_in_book_indeces/up.sql

@@ -0,0 +1,11 @@
+-- Your SQL goes here
+
+CREATE TABLE word_in_book_indexs (
+    id           SERIAL PRIMARY KEY,
+
+    book_id      INTEGER NOT NULL, 
+    pali_word_index_id       INTEGER NOT NULL, 
+    count       INTEGER NOT NULL, 
+
+    created_at   TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);

+ 5 - 0
db/go/20210817135430-create-bolds/down.sql

@@ -0,0 +1,5 @@
+-- This file should undo anything in `up.sql`
+
+DROP INDEX bolds_word_real ;
+DROP TABLE bolds;
+

+ 14 - 0
db/go/20210817135430-create-bolds/up.sql

@@ -0,0 +1,14 @@
+-- Your SQL goes here
+
+CREATE TABLE bolds (
+    id           SERIAL PRIMARY KEY,
+
+    book_id      INTEGER NOT NULL, 
+    paragraph       INTEGER NOT NULL, 
+    word_spell       VARCHAR(512) NOT NULL, 
+    word_real       VARCHAR(512) NOT NULL, 
+    word_en       VARCHAR(512) NOT NULL, 
+
+    created_at   TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+CREATE INDEX bolds_word_real ON bolds (word_real);

+ 8 - 0
db/go/20210817140053-create-sub_books/down.sql

@@ -0,0 +1,8 @@
+-- This file should undo anything in `up.sql`
+
+DROP INDEX  sub_books_book_para ;
+DROP INDEX  sub_books_title ;
+DROP INDEX  sub_books_set_title ;
+
+DROP TABLE sub_books;
+

+ 17 - 0
db/go/20210817140053-create-sub_books/up.sql

@@ -0,0 +1,17 @@
+-- Your SQL goes here
+
+CREATE TABLE sub_books (
+    id           SERIAL PRIMARY KEY,
+
+    book_id INTEGER NOT NULL, 
+    paragraph INTEGER NOT NULL, 
+
+    title    VARCHAR(255) NOT NULL, 
+    set_title    VARCHAR(255) NOT NULL, 
+
+    created_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+);
+
+CREATE INDEX sub_books_book_para ON sub_books (book_id,paragraph);
+CREATE INDEX sub_books_title ON sub_books (title);
+CREATE INDEX sub_books_set_title ON sub_books (set_title);

+ 5 - 0
db/go/20210817140800-create-wbws/down.sql

@@ -0,0 +1,5 @@
+-- This file should undo anything in `up.sql`
+DROP INDEX wbws_unique ;
+DROP INDEX wbws_word ;
+
+DROP TABLE wbws;

+ 34 - 0
db/go/20210817140800-create-wbws/up.sql

@@ -0,0 +1,34 @@
+-- Your SQL goes here
+
+CREATE TABLE wbws (
+    id           SERIAL PRIMARY KEY,
+    pr_parent_id INTEGER ,
+
+    wbws_index_id     INTEGER ,
+    channel_id   INTEGER ,
+    
+    book_id      INTEGER  NOT NULL,
+    paragraph    INTEGER  NOT NULL,
+    sn        INTEGER  NOT NULL,
+
+    word         VARCHAR (512) NOT NULL,
+    data      TEXT,
+    
+    lang         VARCHAR (16) NOT NULL DEFAULT('en'),
+
+    status TStatus  NOT NULL DEFAULT('private'), 
+
+    editor_id INTEGER  NOT NULL,
+    owner_id INTEGER  NOT NULL,
+
+	version     INTEGER NOT NULL DEFAULT (1),
+    deleted_at  TIMESTAMP,
+
+    created_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+    updated_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+
+CREATE INDEX wbws_unique ON wbws (channel_id,book_id,paragraph,sn);
+CREATE INDEX wbws_word ON wbws (word);
+

+ 4 - 0
db/go/20210817141841-create-wbws_indeces/down.sql

@@ -0,0 +1,4 @@
+-- This file should undo anything in `up.sql`
+DROP INDEX wbws_indexs_unique ;
+
+DROP TABLE wbws_indexs;

+ 19 - 0
db/go/20210817141841-create-wbws_indeces/up.sql

@@ -0,0 +1,19 @@
+-- Your SQL goes here
+
+CREATE TABLE wbws_indexs (
+    id           SERIAL PRIMARY KEY,
+
+    channel_id   INTEGER ,
+    
+    book_id      INTEGER  NOT NULL,
+    paragraph    INTEGER  NOT NULL,
+
+    owner_id INTEGER  NOT NULL,
+
+    created_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+    updated_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+
+CREATE INDEX wbws_indexs_unique ON wbws_indexs (channel_id,book_id,paragraph);
+

+ 4 - 0
db/go/20210818145019-create-wbws_lists/down.sql

@@ -0,0 +1,4 @@
+-- This file should undo anything in `up.sql`
+DROP INDEX wbws_lists_title ;
+
+DROP TABLE wbws_lists;

+ 27 - 0
db/go/20210818145019-create-wbws_lists/up.sql

@@ -0,0 +1,27 @@
+-- Your SQL goes here
+
+CREATE TABLE wbws_lists (
+    id          SERIAL PRIMARY KEY,
+
+    parent_id   INTEGER ,
+    channel_id  INTEGER ,
+    book_id     INTEGER ,
+    paragraph   INTEGER ,
+    title       VARCHAR(255)  NOT NULL,
+
+
+    setting     TEXT  NOT NULL,
+    content     JSON  NOT NULL,
+
+    status      TStatus  NOT NULL,    
+    owner_id    INTEGER NOT NULL,
+	version     INTEGER NOT NULL DEFAULT (1),
+    deleted_at  TIMESTAMP,
+
+    created_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+    updated_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+
+CREATE INDEX wbws_lists_title ON wbws_lists (title);
+

+ 7 - 0
db/go/20210823022504-create-comments/down.sql

@@ -0,0 +1,7 @@
+-- This file should undo anything in `up.sql`
+DROP INDEX comments_title ;
+DROP INDEX comments_uid ;
+
+DROP TABLE comments;
+
+DROP TYPE TCommentStatus;

+ 27 - 0
db/go/20210823022504-create-comments/up.sql

@@ -0,0 +1,27 @@
+-- Your SQL goes here
+CREATE TYPE TCommentStatus AS ENUM ('disable','checking','checked');
+
+CREATE TABLE comments (
+    id          SERIAL PRIMARY KEY,
+    uid         VARCHAR(36)  NOT NULL,
+
+    parent_id   INTEGER NOT NULL,
+    parent_type   TResourceType NOT NULL,
+
+    title       VARCHAR(255)  NOT NULL,
+
+    content     TEXT  NOT NULL,
+    content_type TContentType NOT NULL DEFAULT ('markdown'),
+    
+    status      TCommentStatus  NOT NULL DEFAULT ('checking'),    
+    owner_id    INTEGER NOT NULL,
+	version     INTEGER NOT NULL DEFAULT (1),
+
+    created_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+    updated_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+
+CREATE INDEX comments_title ON comments (title);
+CREATE UNIQUE INDEX comments_uid ON comments (uid);
+

+ 6 - 0
db/go/20210827095853-create-studio/down.sql

@@ -0,0 +1,6 @@
+-- This file should undo anything in `up.sql`
+DROP INDEX studios_name ;
+DROP INDEX studios_uid ;
+
+DROP TABLE studios;
+

+ 22 - 0
db/go/20210827095853-create-studio/up.sql

@@ -0,0 +1,22 @@
+-- Your SQL goes here
+CREATE TABLE studios (
+    id          SERIAL PRIMARY KEY,
+    uid         VARCHAR(36)  NOT NULL,
+
+    name       VARCHAR(255)  NOT NULL,
+
+    profile     TEXT  NOT NULL DEFAULT (''),
+    profile_type TContentType NOT NULL DEFAULT ('markdown'),
+    
+    status      TStatus  NOT NULL DEFAULT ('public'),
+    creator_id    INTEGER NOT NULL,
+	version     INTEGER NOT NULL DEFAULT (1),
+
+    created_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+    updated_at  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+
+CREATE UNIQUE INDEX studios_name ON studios (name);
+CREATE UNIQUE INDEX studios_uid ON studios (uid);
+