Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit064c27f

Browse files
committed
fixup! chore: update v1 schema
1 parentd769bd5 commit064c27f

File tree

3 files changed

+113
-0
lines changed

3 files changed

+113
-0
lines changed

‎coderd/database/dump.sql

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
DROPINDEX idx_organization_member_user_id_uuid;
2+
DROPINDEX idx_organization_member_organization_id_uuid;
3+
4+
DROPTRIGGER trig_uuid_to_longid_usersON users;
5+
DROPTRIGGER trig_uuid_to_longid_organizationsON organizations;
6+
DROPTRIGGER trig_uuid_to_longid_organization_members_user_idON organization_members;
7+
DROPTRIGGER trig_uuid_to_longid_organization_members_org_idON organization_members;
8+
9+
DROPFUNCTION org_uuid_to_longid_trigger;
10+
DROPFUNCTION user_uuid_to_longid_trigger;
11+
DROPFUNCTION uuid_to_longid_trigger;

‎coderd/database/migrations/000001_base.up.sql

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,36 @@ EXCEPTION
3535
WHEN duplicate_object THENnull;
3636
END $$;
3737

38+
CREATEFUNCTIONuuid_to_longid_trigger() RETURNS triggerAS $$
39+
BEGIN
40+
ifNEW.id_old ISNULL THEN
41+
NEW.id_old :=NEW.id::text;
42+
END if;
43+
44+
return NEW;
45+
END;
46+
$$ LANGUAGE plpgsql;
47+
48+
CREATEFUNCTIONuser_uuid_to_longid_trigger() RETURNS triggerAS $$
49+
BEGIN
50+
ifNEW.user_id_old ISNULL THEN
51+
NEW.user_id_old :=NEW.user_id::text;
52+
END if;
53+
54+
return NEW;
55+
END;
56+
$$ LANGUAGE plpgsql;
57+
58+
CREATEFUNCTIONorg_uuid_to_longid_trigger() RETURNS triggerAS $$
59+
BEGIN
60+
ifNEW.organization_id_old ISNULL THEN
61+
NEW.organization_id_old :=NEW.organization_id::text;
62+
END if;
63+
64+
return NEW;
65+
END;
66+
$$ LANGUAGE plpgsql;
67+
3868
--
3969
-- Name: users; Type: TABLE; Schema: public; Owner: coder
4070
--
@@ -71,6 +101,13 @@ CREATE UNIQUE INDEX IF NOT EXISTS idx_users_id_uuid ON users USING btree (id);
71101
CREATEUNIQUE INDEXIF NOT EXISTS idx_users_usernameON users USING btree (username);
72102
CREATEUNIQUE INDEXIF NOT EXISTS users_username_lower_idxON users USING btree (lower(username));
73103

104+
CREATE TRIGGER
105+
trig_uuid_to_longid_users
106+
BEFORE INSERTON
107+
users
108+
FOR EACH ROW EXECUTE PROCEDURE
109+
uuid_to_longid_trigger();
110+
74111
--
75112
-- Name: organizations; Type: TABLE; Schema: Owner: coder
76113
--
@@ -93,6 +130,13 @@ CREATE TABLE IF NOT EXISTS organizations (
93130
CREATEUNIQUE INDEXIF NOT EXISTS idx_organization_nameON organizations USING btree (name);
94131
CREATEUNIQUE INDEXIF NOT EXISTS idx_organizations_id_uuidON organizations USING btree (id);
95132

133+
CREATE TRIGGER
134+
trig_uuid_to_longid_organizations
135+
BEFORE INSERTON
136+
organizations
137+
FOR EACH ROW EXECUTE PROCEDURE
138+
uuid_to_longid_trigger();
139+
96140
-- ALTER TABLE ONLY organizations
97141
-- ADD CONSTRAINT organizations_pkey PRIMARY KEY (id_old);
98142

@@ -141,6 +185,20 @@ EXCEPTION
141185
WHEN duplicate_object THENnull;
142186
END $$;
143187

188+
CREATE TRIGGER
189+
trig_uuid_to_longid_organization_members_user_id
190+
BEFORE INSERTON
191+
organization_members
192+
FOR EACH ROW EXECUTE PROCEDURE
193+
user_uuid_to_longid_trigger();
194+
195+
CREATE TRIGGER
196+
trig_uuid_to_longid_organization_members_org_id
197+
BEFORE INSERTON
198+
organization_members
199+
FOR EACH ROW EXECUTE PROCEDURE
200+
org_uuid_to_longid_trigger();
201+
144202
CREATETABLEIF NOT EXISTS api_keys (
145203
idtextNOT NULL,
146204
hashed_secretbyteaNOT NULL,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp