Skip to content

Commit 0db434a

Browse files
committed
ammend
1 parent 5d43d6a commit 0db434a

File tree

5 files changed

+21
-22
lines changed

5 files changed

+21
-22
lines changed

migrations/config/intermediate_db.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ schema:
4343
- "created_at"
4444
- "id"
4545
category_users:
46+
primary_key_column_names: [ "category_id", "user_id" ]
4647
columns:
4748
exclude:
4849
- "id"
@@ -72,8 +73,15 @@ schema:
7273
primary_key_column_names: [original_id, channel_id, original_message_id, original_message_user_id ]
7374
group_users:
7475
primary_key_column_names: [ "group_id", "user_id" ]
76+
columns:
77+
exclude:
78+
- "id"
79+
- "created_at"
7580
groups:
7681
columns:
82+
add:
83+
- name: "existing_id"
84+
datatype: text
7785
include:
7886
- "allow_membership_requests"
7987
- "allow_unknown_sender_topic_replies"

migrations/db/intermediate_db_schema/100-base-schema.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ CREATE TABLE category_custom_fields
8888
CREATE TABLE category_users
8989
(
9090
category_id NUMERIC NOT NULL,
91+
user_id NUMERIC NOT NULL,
9192
last_seen_at DATETIME,
9293
notification_level INTEGER NOT NULL,
93-
user_id NUMERIC NOT NULL
94+
PRIMARY KEY (category_id, user_id)
9495
);
9596

9697
CREATE TABLE chat_channels
@@ -173,10 +174,8 @@ CREATE TABLE group_users
173174
(
174175
group_id NUMERIC NOT NULL,
175176
user_id NUMERIC NOT NULL,
176-
created_at DATETIME NOT NULL,
177177
first_unread_pm_at DATETIME NOT NULL,
178178
notification_level INTEGER,
179-
original_id NUMERIC NOT NULL,
180179
owner BOOLEAN,
181180
PRIMARY KEY (group_id, user_id)
182181
);
@@ -191,6 +190,7 @@ CREATE TABLE "groups"
191190
bio_raw TEXT,
192191
created_at DATETIME NOT NULL,
193192
default_notification_level INTEGER,
193+
existing_id TEXT,
194194
flair_bg_color TEXT,
195195
flair_color TEXT,
196196
flair_icon TEXT,

migrations/lib/database/intermediate_db/category_user.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ module CategoryUser
99
SQL = <<~SQL
1010
INSERT INTO category_users (
1111
category_id,
12+
user_id,
1213
last_seen_at,
13-
notification_level,
14-
user_id
14+
notification_level
1515
)
1616
VALUES (
1717
?, ?, ?, ?
1818
)
1919
SQL
2020

21-
def self.create(category_id:, last_seen_at: nil, notification_level:, user_id:)
21+
def self.create(category_id:, user_id:, last_seen_at: nil, notification_level:)
2222
::Migrations::Database::IntermediateDB.insert(
2323
SQL,
2424
category_id,
25+
user_id,
2526
::Migrations::Database.format_datetime(last_seen_at),
2627
notification_level,
27-
user_id,
2828
)
2929
end
3030
end

migrations/lib/database/intermediate_db/group.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module Group
1616
bio_raw,
1717
created_at,
1818
default_notification_level,
19+
existing_id,
1920
flair_bg_color,
2021
flair_color,
2122
flair_icon,
@@ -34,7 +35,7 @@ module Group
3435
visibility_level
3536
)
3637
VALUES (
37-
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
38+
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
3839
)
3940
SQL
4041

@@ -47,6 +48,7 @@ def self.create(
4748
bio_raw: nil,
4849
created_at:,
4950
default_notification_level: nil,
51+
existing_id: nil,
5052
flair_bg_color: nil,
5153
flair_color: nil,
5254
flair_icon: nil,
@@ -74,6 +76,7 @@ def self.create(
7476
bio_raw,
7577
::Migrations::Database.format_datetime(created_at),
7678
default_notification_level,
79+
existing_id,
7780
flair_bg_color,
7881
flair_color,
7982
flair_icon,

migrations/lib/database/intermediate_db/group_user.rb

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,22 @@ module GroupUser
1010
INSERT INTO group_users (
1111
group_id,
1212
user_id,
13-
created_at,
1413
first_unread_pm_at,
1514
notification_level,
16-
original_id,
1715
owner
1816
)
1917
VALUES (
20-
?, ?, ?, ?, ?, ?, ?
18+
?, ?, ?, ?, ?
2119
)
2220
SQL
2321

24-
def self.create(
25-
group_id:,
26-
user_id:,
27-
created_at:,
28-
first_unread_pm_at:,
29-
notification_level: nil,
30-
original_id:,
31-
owner: nil
32-
)
22+
def self.create(group_id:, user_id:, first_unread_pm_at:, notification_level: nil, owner: nil)
3323
::Migrations::Database::IntermediateDB.insert(
3424
SQL,
3525
group_id,
3626
user_id,
37-
::Migrations::Database.format_datetime(created_at),
3827
::Migrations::Database.format_datetime(first_unread_pm_at),
3928
notification_level,
40-
original_id,
4129
::Migrations::Database.format_boolean(owner),
4230
)
4331
end

0 commit comments

Comments
 (0)