-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from orekyuu/add-repository-table
リポジトリ登録用のテーブルを用意
- Loading branch information
Showing
5 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
src/main/resources/db/migration/V3__create_repositories.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
CREATE TABLE repositories | ||
( | ||
id int PRIMARY KEY AUTO_INCREMENT, | ||
name varchar(512) NOT NULL, | ||
owner int NOT NULL, | ||
japanese_contribute boolean DEFAULT false NOT NULL, | ||
cla_required boolean DEFAULT false NOT NULL, | ||
registered_at datetime NOT NULL, | ||
CONSTRAINT repositories_accounts_id_fk FOREIGN KEY (owner) REFERENCES accounts (id) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- 選択可能なプログラミング言語のマスタ | ||
CREATE TABLE languages | ||
( | ||
id int PRIMARY KEY AUTO_INCREMENT, | ||
name varchar(512) NOT NULL | ||
); | ||
CREATE UNIQUE INDEX languages_name_uindex ON languages (name); |
8 changes: 8 additions & 0 deletions
8
src/main/resources/db/migration/V5__create_repository_types.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- リポジトリの区分 | ||
CREATE TABLE repository_types | ||
( | ||
id int PRIMARY KEY AUTO_INCREMENT, | ||
name varchar(512) NOT NULL | ||
); | ||
CREATE UNIQUE INDEX repository_type_name_uindex | ||
ON repository_types (name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- フレームワーク・ライブラリの種類 | ||
CREATE TABLE frameworks | ||
( | ||
id int PRIMARY KEY AUTO_INCREMENT, | ||
name varchar(512) NOT NULL | ||
); | ||
CREATE UNIQUE INDEX frameworks_name_uindex ON frameworks (name); |
23 changes: 23 additions & 0 deletions
23
src/main/resources/db/migration/V7__create_repositories-junction-table.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
-- repositoriesとlanguagesの中間テーブル | ||
CREATE TABLE repository_languages | ||
( | ||
repository_id int NOT NULL, | ||
language_id int NOT NULL, | ||
CONSTRAINT repository_languages_repository_id_language_id_pk PRIMARY KEY (repository_id, language_id), | ||
CONSTRAINT repository_languages_repositories_id_fk FOREIGN KEY (repository_id) REFERENCES repositories (id), | ||
CONSTRAINT repository_languages_languages_id_fk FOREIGN KEY (language_id) REFERENCES languages (id) | ||
); | ||
|
||
-- repositoriesとframeworkの中間テーブル | ||
CREATE TABLE repository_frameworks | ||
( | ||
repository_id int NOT NULL, | ||
framework_id int NOT NULL, | ||
CONSTRAINT repository_frameworks_repository_id_framework_id_pk PRIMARY KEY (repository_id, framework_id), | ||
CONSTRAINT repository_frameworks_repositories_id_fk FOREIGN KEY (repository_id) REFERENCES repositories (id), | ||
CONSTRAINT repository_frameworks_frameworks_id_fk FOREIGN KEY (framework_id) REFERENCES frameworks (id) | ||
); | ||
|
||
-- repositoriesにrepository_typeのリレーションを追加 | ||
ALTER TABLE repositories ADD repository_type_id int NOT NULL; | ||
ALTER TABLE repositories ADD CONSTRAINT repositories_repository_types_id_fk FOREIGN KEY (repository_type_id) REFERENCES repository_types (id); |