-
Notifications
You must be signed in to change notification settings - Fork 0
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 #31 from CMIPT/zzq-database-update
Update the primary key of database
- Loading branch information
Showing
11 changed files
with
46 additions
and
60 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,18 +1,12 @@ | ||
-- The constarint of the primary key and unique key is added to the table. | ||
ALTER TABLE ONLY public.t_repository | ||
ADD CONSTRAINT pk_repository PRIMARY KEY (pk_repository_id); | ||
ALTER TABLE ONLY public.t_repository | ||
ADD CONSTRAINT pk_repository PRIMARY KEY (id); | ||
|
||
-- The constraint of t_user is added to the table. | ||
ALTER TABLE ONLY public.t_user | ||
ADD CONSTRAINT pk_user_table PRIMARY KEY (pk_user_id); | ||
ALTER TABLE ONLY public.t_user | ||
ADD CONSTRAINT pk_user_table PRIMARY KEY (id); | ||
|
||
ALTER TABLE ONLY public.t_user | ||
ADD CONSTRAINT users_email_key UNIQUE (email); | ||
|
||
ALTER TABLE ONLY public.t_user | ||
ADD CONSTRAINT users_username_key UNIQUE (username); | ||
|
||
-- The constraint of t_user_repository is not necessary, | ||
-- The constraint of t_user_repository is not necessary, | ||
-- as the primary key is already unique. | ||
ALTER TABLE ONLY public.t_user_repository | ||
ADD CONSTRAINT pk_user_repository PRIMARY KEY (pk_user_repository_id); | ||
ALTER TABLE ONLY public.t_user_repository | ||
ADD CONSTRAINT pk_user_repository PRIMARY KEY (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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,25 +1,25 @@ | ||
CREATE TABLE public.t_repository ( | ||
pk_repository_id bigint DEFAULT nextval('public.repositories_id_seq'::regclass) NOT NULL, | ||
repository_name character varying(255) NOT NULL, | ||
repository_description character varying(255) NOT NULL, | ||
is_private boolean DEFAULT false, | ||
user_id bigint NOT NULL, | ||
id bigint NOT NULL, | ||
repository_name character varying(255) NOT NULL, | ||
repository_description character varying(255) NOT NULL, | ||
is_private boolean DEFAULT false, | ||
user_id bigint NOT NULL, | ||
star integer DEFAULT 0 NOT NULL, | ||
fork integer DEFAULT 0 NOT NULL, | ||
watcher integer DEFAULT 0 NOT NULL, | ||
gmt_created timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
gmt_updated timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
fork integer DEFAULT 0 NOT NULL, | ||
watcher integer DEFAULT 0 NOT NULL, | ||
gmt_created timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
gmt_updated timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
gmt_deleted timestamp without time zone | ||
); | ||
|
||
COMMENT ON TABLE public.t_repository IS 'Table for storing repository information.'; | ||
|
||
COMMENT ON COLUMN public.t_repository.pk_repository_id IS 'Primary key of the repository table.'; | ||
COMMENT ON COLUMN public.t_repository.id IS 'Primary key of the repository table.'; | ||
COMMENT ON COLUMN public.t_repository.repository_name IS 'Name of the repository.'; | ||
COMMENT ON COLUMN public.t_repository.repository_description IS 'Description of the repository.'; | ||
COMMENT ON COLUMN public.t_repository.is_private IS 'Indicates if the repository is private.'; | ||
COMMENT ON COLUMN public.t_repository.user_id IS 'ID of the user who owns the repository.'; | ||
COMMENT ON COLUMN public.t_repository.gmt_created IS 'Timestamp when the repository was created.'; | ||
COMMENT ON COLUMN public.t_repository.gmt_updated IS 'Timestamp when the repository was last updated.'; | ||
COMMENT ON COLUMN public.t_repository.gmt_deleted IS 'Timestamp when the repository was deleted. | ||
COMMENT ON COLUMN public.t_repository.gmt_deleted IS 'Timestamp when the repository was deleted. | ||
If set to NULL, it indicates that the repository has not been deleted.'; |
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
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
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 |
---|---|---|
@@ -1,16 +1,16 @@ | ||
-- The trigger is added to the table. | ||
|
||
-- The trigger of the t_repository table is added. | ||
CREATE TRIGGER update_t_repository_gmt_updated | ||
BEFORE UPDATE ON public.t_repository | ||
CREATE TRIGGER update_t_repository_gmt_updated | ||
BEFORE UPDATE ON public.t_repository | ||
FOR EACH ROW EXECUTE FUNCTION public.update_gmt_updated_column(); | ||
|
||
-- The trigger of the t_user table is added. | ||
CREATE TRIGGER update_t_user_gmt_updated | ||
BEFORE UPDATE ON public.t_user | ||
CREATE TRIGGER update_t_user_gmt_updated | ||
BEFORE UPDATE ON public.t_user | ||
FOR EACH ROW EXECUTE FUNCTION public.update_gmt_updated_column(); | ||
|
||
-- The trigger of the t_user_repository table is added. | ||
CREATE TRIGGER update_t_user_repository_gmt_updated | ||
BEFORE UPDATE ON public.t_user_repository | ||
CREATE TRIGGER update_t_user_repository_gmt_updated | ||
BEFORE UPDATE ON public.t_user_repository | ||
FOR EACH ROW EXECUTE FUNCTION public.update_gmt_updated_column(); |