Skip to content

Commit

Permalink
Define SQL formatting (#384)
Browse files Browse the repository at this point in the history
* Define SQL formatting

* Define SQL formatting
  • Loading branch information
neekolas authored Apr 25, 2024
1 parent cb1822f commit 520f1c1
Show file tree
Hide file tree
Showing 14 changed files with 348 additions and 280 deletions.
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp

// List of extensions which should be recommended for users of this workspace.
"recommendations": ["bradymholt.pgformatter", "golang.go"],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": []
}
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"pgFormatter.typeCase": "uppercase",
"pgFormatter.tabs": true,
"[sql]": {
"editor.defaultFormatter": "bradymholt.pgformatter"
}
}
4 changes: 2 additions & 2 deletions pkg/migrations/mls/20231023050806_init-schema.down.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SET
statement_timeout = 0;
SET statement_timeout = 0;

--bun:split
DROP TABLE IF EXISTS installations;

23 changes: 11 additions & 12 deletions pkg/migrations/mls/20231023050806_init-schema.up.sql
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
SET
statement_timeout = 0;
SET statement_timeout = 0;

--bun:split
CREATE TABLE installations (
id BYTEA PRIMARY KEY,
wallet_address TEXT NOT NULL,
created_at BIGINT NOT NULL,
updated_at BIGINT NOT NULL,
credential_identity BYTEA NOT NULL,
revoked_at BIGINT,

key_package BYTEA NOT NULL,
expiration BIGINT NOT NULL
CREATE TABLE installations(
id BYTEA PRIMARY KEY,
wallet_address TEXT NOT NULL,
created_at BIGINT NOT NULL,
updated_at BIGINT NOT NULL,
credential_identity BYTEA NOT NULL,
revoked_at BIGINT,
key_package BYTEA NOT NULL,
expiration BIGINT NOT NULL
);

--bun:split
Expand All @@ -22,3 +20,4 @@ CREATE INDEX idx_installations_created_at ON installations(created_at);

--bun:split
CREATE INDEX idx_installations_revoked_at ON installations(revoked_at);

1 change: 0 additions & 1 deletion pkg/migrations/mls/20240109001927_add-messages.down.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
SET statement_timeout = 0;

--bun:split

DROP TABLE IF EXISTS messages;

33 changes: 14 additions & 19 deletions pkg/migrations/mls/20240109001927_add-messages.up.sql
Original file line number Diff line number Diff line change
@@ -1,37 +1,32 @@
SET statement_timeout = 0;

--bun:split

CREATE TABLE group_messages (
id BIGSERIAL PRIMARY KEY,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
group_id BYTEA NOT NULL,
data BYTEA NOT NULL,
group_id_data_hash BYTEA NOT NULL
CREATE TABLE group_messages(
id BIGSERIAL PRIMARY KEY,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
group_id BYTEA NOT NULL,
data BYTEA NOT NULL,
group_id_data_hash BYTEA NOT NULL
);

--bun:split

CREATE INDEX idx_group_messages_group_id_created_at ON group_messages(group_id, created_at);

--bun:split

CREATE UNIQUE INDEX idx_group_messages_group_id_data_hash ON group_messages (group_id_data_hash);
CREATE UNIQUE INDEX idx_group_messages_group_id_data_hash ON group_messages(group_id_data_hash);

--bun:split

CREATE TABLE welcome_messages (
id BIGSERIAL PRIMARY KEY,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
installation_key BYTEA NOT NULL,
data BYTEA NOT NULL,
installation_key_data_hash BYTEA NOT NULL
CREATE TABLE welcome_messages(
id BIGSERIAL PRIMARY KEY,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
installation_key BYTEA NOT NULL,
data BYTEA NOT NULL,
installation_key_data_hash BYTEA NOT NULL
);

--bun:split

CREATE INDEX idx_welcome_messages_installation_key_created_at ON welcome_messages(installation_key, created_at);

--bun:split
CREATE UNIQUE INDEX idx_welcome_messages_group_key_data_hash ON welcome_messages(installation_key_data_hash);

CREATE UNIQUE INDEX idx_welcome_messages_group_key_data_hash ON welcome_messages (installation_key_data_hash);
3 changes: 2 additions & 1 deletion pkg/migrations/mls/20240122230601_add-hpke-key.down.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
SET statement_timeout = 0;

ALTER TABLE welcome_messages
DROP COLUMN IF EXISTS hpke_public_key BYTEA;
DROP COLUMN IF EXISTS hpke_public_key BYTEA;

3 changes: 2 additions & 1 deletion pkg/migrations/mls/20240122230601_add-hpke-key.up.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
SET statement_timeout = 0;

ALTER TABLE welcome_messages
ADD COLUMN hpke_public_key BYTEA;
ADD COLUMN hpke_public_key BYTEA;

3 changes: 1 addition & 2 deletions pkg/migrations/mls/20240411200242_init-identity.down.sql
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
SET statement_timeout = 0;

--bun:split

DROP TABLE IF EXISTS inbox_log;

--bun:split

DROP TABLE IF EXISTS address_log;

23 changes: 12 additions & 11 deletions pkg/migrations/mls/20240411200242_init-identity.up.sql
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
SET statement_timeout = 0;

--bun:split
CREATE TABLE inbox_log (
sequence_id BIGSERIAL PRIMARY KEY,
inbox_id TEXT NOT NULL,
server_timestamp_ns BIGINT NOT NULL,
identity_update_proto BYTEA NOT NULL
CREATE TABLE inbox_log(
sequence_id BIGSERIAL PRIMARY KEY,
inbox_id TEXT NOT NULL,
server_timestamp_ns BIGINT NOT NULL,
identity_update_proto BYTEA NOT NULL
);

--bun:split
CREATE INDEX idx_inbox_log_inbox_id ON inbox_log(inbox_id);

--bun:split
CREATE TABLE address_log (
address TEXT NOT NULL,
inbox_id TEXT NOT NULL,
association_sequence_id BIGINT,
revocation_sequence_id BIGINT
CREATE TABLE address_log(
address TEXT NOT NULL,
inbox_id TEXT NOT NULL,
association_sequence_id BIGINT,
revocation_sequence_id BIGINT
);

--bun:split
CREATE INDEX idx_address_log_address_inbox_id ON address_log(address, inbox_id);
CREATE INDEX idx_address_log_address_inbox_id ON address_log(address, inbox_id);

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SET statement_timeout = 0;

--bun:split
DROP TYPE IF EXISTS inbox_filter;

DROP TYPE IF EXISTS inbox_filter;
6 changes: 3 additions & 3 deletions pkg/migrations/mls/20240425021053_add-inbox-filters.up.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
SET statement_timeout = 0;

--bun:split

CREATE TYPE inbox_filter AS (
inbox_id TEXT,
sequence_id BIGINT
inbox_id TEXT,
sequence_id BIGINT
);

Loading

0 comments on commit 520f1c1

Please sign in to comment.