Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

chore: consolidate notificationdb to macrodb (#1178)

Will Hutchinsonf2dc8e29ae74
diff --git a/infra/stacks/notification-service/Pulumi.dev.yaml b/infra/stacks/notification-service/Pulumi.dev.yaml
index 8bca3840e5..037c17b3b3 100644
--- a/infra/stacks/notification-service/Pulumi.dev.yaml
+++ b/infra/stacks/notification-service/Pulumi.dev.yaml
@@ -14,3 +14,4 @@ config:
notification-service:fcm_secret_key: fcm-credential-dev
notification-service:macro_cache_secret_key: macro-cache-dev
notification-service:authentication_service_internal_api_key: authentication-service-internal-api-key-dev
+ notification-service:macro_db_secret_key: macro-db-dev
diff --git a/infra/stacks/notification-service/Pulumi.prod.yaml b/infra/stacks/notification-service/Pulumi.prod.yaml
index f605fbc866..ba9cf513f5 100644
--- a/infra/stacks/notification-service/Pulumi.prod.yaml
+++ b/infra/stacks/notification-service/Pulumi.prod.yaml
@@ -14,3 +14,4 @@ config:
notification-service:fcm_secret_key: fcm-credential-prod
notification-service:macro_cache_secret_key: macro-cache-prod
notification-service:authentication_service_internal_api_key: authentication-service-internal-api-key-prod
+ notification-service:macro_db_secret_key: macro-db-prod
diff --git a/infra/stacks/notification-service/index.ts b/infra/stacks/notification-service/index.ts
index 2e6e0a6ba4..634c25679b 100644
--- a/infra/stacks/notification-service/index.ts
+++ b/infra/stacks/notification-service/index.ts
@@ -105,11 +105,11 @@ const notificationDb = new Database('notification-db', {
export const notificationDatabaseEndpoint = notificationDb.endpoint;
-const DATABASE_URL = pulumi.all([notificationDatabaseEndpoint, password]).apply(
- // eslint-disable-next-line @typescript-eslint/no-shadow
- ([endpoint, password]) =>
- `postgresql://macrouser:${password}@${endpoint}/notificationdb`
-);
+const DATABASE_URL = aws.secretsmanager
+ .getSecretVersionOutput({
+ secretId: config.require(`macro_db_secret_key`),
+ })
+ .apply((secret) => secret.secretString);
const notificationQueue = new Queue('notification', {
tags,
diff --git a/rust/cloud-storage/CLAUDE.md b/rust/cloud-storage/CLAUDE.md
index b0a071f2f5..b55f296179 100644
--- a/rust/cloud-storage/CLAUDE.md
+++ b/rust/cloud-storage/CLAUDE.md
@@ -41,8 +41,7 @@ from the cloud-storage folder.
The system uses multiple databases:
- **MacroDB**: Main PostgreSQL database for documents, users, projects, Communication data (messages, channels,
- participants), Email threads, messages, and metadata
-- **NotificationDB**: Notification preferences and history
+ participants), Email threads, messages, metadata, and notification preferences/history
- **ContactsDB**: User connections and contacts
External storage includes S3 for document files, Redis for caching, OpenSearch for search indexing, and DynamoDB for
@@ -102,7 +101,6 @@ just clippy # extra lints / best practices
```bash
just setup_macrodb # Setup main database
just setup_commsdb # Setup communications database
-just setup_notificationdb # Setup notifications database
just setup_emaildb # Setup email database
just setup_contactsdb # Setup contacts database
```
diff --git a/rust/cloud-storage/Cargo.lock b/rust/cloud-storage/Cargo.lock
index 25931a0885..ebaea932c5 100644
--- a/rust/cloud-storage/Cargo.lock
+++ b/rust/cloud-storage/Cargo.lock
@@ -5875,6 +5875,7 @@ version = "0.1.0"
dependencies = [
"anyhow",
"chrono",
+ "macro_db_migrator",
"macro_user_id",
"macro_uuid",
"model",
diff --git a/rust/cloud-storage/justfile b/rust/cloud-storage/justfile
index 3f5282f142..b52d90b5bd 100644
--- a/rust/cloud-storage/justfile
+++ b/rust/cloud-storage/justfile
@@ -54,8 +54,8 @@ build_lambdas:
# Copies over necessary .env files for sqlx tests
setup_test_envs:
- echo "DATABASE_URL={{ DATABASE_URL }}/notificationdb" >> ./notification_db_client/.env
echo "DATABASE_URL={{ DATABASE_URL }}/contacts" >> ./contacts_db_client/.env
+ echo "DATABASE_URL={{ MACRODB }}" >> ./notification_db_client/.env
echo "DATABASE_URL={{ MACRODB }}" >> ./properties_db_client/.env
echo "DATABASE_URL={{ MACRODB }}" >> ./macro_db_client/.env
echo "DATABASE_URL={{ MACRODB }}" >> ./email_db_client/.env
@@ -86,7 +86,5 @@ setup_macrodb:
just document_cognition_service/prepare-test
initialize_dbs: setup_macrodb
- # notificationdb
- just notification_db_client/setup
# contactsdb
just contacts_db_client/setup
diff --git a/rust/cloud-storage/macro_db_client/migrations/20260126170641_create_notification_tables.sql b/rust/cloud-storage/macro_db_client/migrations/20260126170641_create_notification_tables.sql
new file mode 100644
index 0000000000..0830dcdc73
--- /dev/null
+++ b/rust/cloud-storage/macro_db_client/migrations/20260126170641_create_notification_tables.sql
@@ -0,0 +1,115 @@
+-- Consolidated notification schema for macrodb
+-- This is a single migration combining all notification tables
+
+-- ============================================================================
+-- TYPES
+-- ============================================================================
+
+CREATE TYPE notification_device_type_option AS ENUM ('ios', 'android');
+
+-- ============================================================================
+-- TABLES
+-- ============================================================================
+
+-- Main notification table
+CREATE TABLE notification (
+ id UUID PRIMARY KEY NOT NULL, -- id of notification, self-generated UUIDv7
+ notification_event_type VARCHAR(255) NOT NULL, -- the type of notification that this event generates
+ event_item_id TEXT NOT NULL, -- id of the relevant item that is triggering the notification
+ event_item_type TEXT NOT NULL, -- type of the relevant item that is triggering the notification
+ service_sender TEXT NOT NULL, -- what service generated the notification
+ created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- time notification was created
+ metadata JSONB, -- any custom metadata that may be needed for the notification
+ sender_id TEXT, -- id of the sender
+ apns_collapse_key TEXT -- iOS push notification collapse key
+);
+
+-- User notification junction table
+CREATE TABLE user_notification (
+ user_id TEXT NOT NULL, -- user id
+ notification_id UUID NOT NULL REFERENCES notification (id) ON DELETE CASCADE, -- notification id
+ created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- time user notification was created
+ sent BOOLEAN NOT NULL DEFAULT FALSE, -- whether the notification has been sent
+ seen_at TIMESTAMP, -- time the notification was seen
+ deleted_at TIMESTAMP, -- time the notification was deleted
+ done BOOLEAN NOT NULL DEFAULT FALSE, -- whether user marked it done
+ is_important_v0 BOOLEAN NOT NULL DEFAULT FALSE, -- importance flag
+ PRIMARY KEY (user_id, notification_id)
+);
+
+-- Table to store all email addresses that have unsubscribed from notifications
+CREATE TABLE notification_email_unsubscribe (
+ email TEXT PRIMARY KEY
+);
+
+-- User unsubscribe from specific items
+CREATE TABLE user_notification_item_unsubscribe (
+ user_id TEXT NOT NULL,
+ item_id TEXT NOT NULL,
+ item_type TEXT NOT NULL,
+ PRIMARY KEY (user_id, item_id)
+);
+
+-- Email unsubscribe code for email links (renamed with notification_ prefix)
+CREATE TABLE notification_email_unsubscribe_code (
+ email TEXT PRIMARY KEY, -- The email address should be lowercased before insertion
+ code UUID UNIQUE NOT NULL -- UUID used in the email unsubscribe link
+);
+
+-- User device registration for push notifications (renamed with notification_ prefix)
+CREATE TABLE notification_user_device_registration (
+ id UUID PRIMARY KEY NOT NULL, -- registration id, self-generated UUIDv7
+ user_id TEXT NOT NULL, -- user associated with the device
+ device_token TEXT NOT NULL, -- device-app combo from registering with a Push Notification Service
+ device_endpoint TEXT UNIQUE NOT NULL, -- push notification endpoint, must be unique; index is auto-created
+ device_type notification_device_type_option NOT NULL, -- type of device (ios | android)
+ created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- time registration was created
+ updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- time endpoint was updated
+ last_used_at TIMESTAMP -- time endpoint was last used to send a notification
+);
+
+-- Channel notification email sent tracking
+CREATE TABLE channel_notification_email_sent (
+ channel_id UUID NOT NULL, -- the id of the channel
+ user_id TEXT NOT NULL, -- the id of the user
+ created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (channel_id, user_id) -- composite primary key
+);
+
+-- User mute notification setting
+CREATE TABLE user_mute_notification (
+ user_id TEXT PRIMARY KEY -- the user who has muted notifications
+);
+
+-- Notification email sent tracking
+CREATE TABLE notification_email_sent (
+ user_id TEXT PRIMARY KEY NOT NULL, -- the id of the user
+ sent_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+-- ============================================================================
+-- INDEXES
+-- ============================================================================
+
+-- notification indexes
+CREATE INDEX idx_notification_event ON notification (event_item_id);
+CREATE INDEX idx_notification_event_item_type ON notification (event_item_type);
+
+-- user_notification indexes
+CREATE INDEX idx_user_notification_user ON user_notification (user_id);
+CREATE INDEX idx_user_notification_notification ON user_notification (notification_id);
+
+-- user_notification_item_unsubscribe indexes
+CREATE INDEX idx_user_notification_item_unsubscribe_user_id ON user_notification_item_unsubscribe (user_id);
+CREATE INDEX idx_user_notification_item_unsubscribe_item_id ON user_notification_item_unsubscribe (item_id);
+
+-- notification_email_unsubscribe_code indexes
+CREATE UNIQUE INDEX notification_email_unsubscribe_code_code_idx ON notification_email_unsubscribe_code (code);
+
+-- notification_user_device_registration indexes
+CREATE INDEX idx_notification_user_device_registration_user ON notification_user_device_registration (user_id);
+CREATE INDEX idx_notification_user_device_registration_device_token ON notification_user_device_registration (device_token);
+
+-- channel_notification_email_sent indexes
+CREATE INDEX idx_channel_notification_email_sent_channel ON channel_notification_email_sent (channel_id);
+CREATE INDEX idx_channel_notification_email_sent_user ON channel_notification_email_sent (user_id);
diff --git a/rust/cloud-storage/model_notifications/src/device.rs b/rust/cloud-storage/model_notifications/src/device.rs
index 8de9af1c60..262279be93 100644
--- a/rust/cloud-storage/model_notifications/src/device.rs
+++ b/rust/cloud-storage/model_notifications/src/device.rs
@@ -5,7 +5,10 @@ use utoipa::ToSchema;
#[derive(Serialize, Deserialize, Debug, ToSchema, Type, EnumString, Display, Eq, PartialEq)]
#[serde(rename_all = "lowercase")]
-#[sqlx(type_name = "device_type_option", rename_all = "lowercase")]
+#[sqlx(
+ type_name = "notification_device_type_option",
+ rename_all = "lowercase"
+)]
#[strum(serialize_all = "lowercase")]
pub enum DeviceType {
Ios,
diff --git a/rust/cloud-storage/notification_db_client/.sqlx/query-0b9eab7e8622c0cf125e26ea14f114e2cc02a12ffc82489a835e9422d9284eda.json b/rust/cloud-storage/notification_db_client/.sqlx/query-0b9eab7e8622c0cf125e26ea14f114e2cc02a12ffc82489a835e9422d9284eda.json
deleted file mode 100644
index 7ba41d76b5..0000000000
--- a/rust/cloud-storage/notification_db_client/.sqlx/query-0b9eab7e8622c0cf125e26ea14f114e2cc02a12ffc82489a835e9422d9284eda.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n INSERT INTO email_unsubscribe_code (email, code) VALUES ($1, $2)\n ON CONFLICT (email) DO UPDATE \n SET code = email_unsubscribe_code.code\n RETURNING email_unsubscribe_code.code\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "code",
- "type_info": "Uuid"
- }
- ],
- "parameters": {
- "Left": [
- "Text",
- "Uuid"
- ]
- },
- "nullable": [
- false
- ]
- },
- "hash": "0b9eab7e8622c0cf125e26ea14f114e2cc02a12ffc82489a835e9422d9284eda"
-}
diff --git a/rust/cloud-storage/notification_db_client/.sqlx/query-7d1fdc289bf4530e6232497d1a324732546a62dbf7df1e1d5265f9f6bc5ed7ca.json b/rust/cloud-storage/notification_db_client/.sqlx/query-19c878ce5817c5643e48a6159fce81a2f964defcb7b190460f2b16ac67078766.json
similarity index 60%
rename from rust/cloud-storage/notification_db_client/.sqlx/query-7d1fdc289bf4530e6232497d1a324732546a62dbf7df1e1d5265f9f6bc5ed7ca.json
rename to rust/cloud-storage/notification_db_client/.sqlx/query-19c878ce5817c5643e48a6159fce81a2f964defcb7b190460f2b16ac67078766.json
index 31c023fcb7..afeebdd674 100644
--- a/rust/cloud-storage/notification_db_client/.sqlx/query-7d1fdc289bf4530e6232497d1a324732546a62dbf7df1e1d5265f9f6bc5ed7ca.json
+++ b/rust/cloud-storage/notification_db_client/.sqlx/query-19c878ce5817c5643e48a6159fce81a2f964defcb7b190460f2b16ac67078766.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n DELETE FROM user_device_registration\n WHERE device_token = $1 AND device_type = $2\n RETURNING device_endpoint\n ",
+ "query": "\n DELETE FROM notification_user_device_registration\n WHERE device_token = $1 AND device_type = $2\n RETURNING device_endpoint\n ",
"describe": {
"columns": [
{
@@ -14,7 +14,7 @@
"Text",
{
"Custom": {
- "name": "device_type_option",
+ "name": "notification_device_type_option",
"kind": {
"Enum": [
"ios",
@@ -29,5 +29,5 @@
false
]
},
- "hash": "7d1fdc289bf4530e6232497d1a324732546a62dbf7df1e1d5265f9f6bc5ed7ca"
+ "hash": "19c878ce5817c5643e48a6159fce81a2f964defcb7b190460f2b16ac67078766"
}
diff --git a/rust/cloud-storage/notification_db_client/.sqlx/query-406315af05d2ab4d58a328e6d49eddd181b11339c2d817e2e33568cf731dcd62.json b/rust/cloud-storage/notification_db_client/.sqlx/query-1dfe7b9de91625d4dafc473dd014326d84465827ee265f1111cd30e6d936f714.json
similarity index 59%
rename from rust/cloud-storage/notification_db_client/.sqlx/query-406315af05d2ab4d58a328e6d49eddd181b11339c2d817e2e33568cf731dcd62.json
rename to rust/cloud-storage/notification_db_client/.sqlx/query-1dfe7b9de91625d4dafc473dd014326d84465827ee265f1111cd30e6d936f714.json
index 9dccde6b40..b2923990ae 100644
--- a/rust/cloud-storage/notification_db_client/.sqlx/query-406315af05d2ab4d58a328e6d49eddd181b11339c2d817e2e33568cf731dcd62.json
+++ b/rust/cloud-storage/notification_db_client/.sqlx/query-1dfe7b9de91625d4dafc473dd014326d84465827ee265f1111cd30e6d936f714.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT email FROM email_unsubscribe_code WHERE code = $1\n ",
+ "query": "\n SELECT email FROM notification_email_unsubscribe_code WHERE code = $1\n ",
"describe": {
"columns": [
{
@@ -18,5 +18,5 @@
false
]
},
- "hash": "406315af05d2ab4d58a328e6d49eddd181b11339c2d817e2e33568cf731dcd62"
+ "hash": "1dfe7b9de91625d4dafc473dd014326d84465827ee265f1111cd30e6d936f714"
}
diff --git a/rust/cloud-storage/notification_db_client/.sqlx/query-24664715280fd1a05397a93d1e21c3e953b1523991bbe59186c0f423cc593c7a.json b/rust/cloud-storage/notification_db_client/.sqlx/query-24664715280fd1a05397a93d1e21c3e953b1523991bbe59186c0f423cc593c7a.json
deleted file mode 100644
index d05ba83bd9..0000000000
--- a/rust/cloud-storage/notification_db_client/.sqlx/query-24664715280fd1a05397a93d1e21c3e953b1523991bbe59186c0f423cc593c7a.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n INSERT INTO user_device_registration (id, user_id, device_token, device_endpoint, device_type)\n VALUES ($1, $2, $3, $4, $5)\n ON CONFLICT (device_endpoint) DO UPDATE SET user_id = $2, device_token = $3, device_type = $5, updated_at = NOW()\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Uuid",
- "Text",
- "Text",
- "Text",
- {
- "Custom": {
- "name": "device_type_option",
- "kind": {
- "Enum": [
- "ios",
- "android"
- ]
- }
- }
- }
- ]
- },
- "nullable": []
- },
- "hash": "24664715280fd1a05397a93d1e21c3e953b1523991bbe59186c0f423cc593c7a"
-}
diff --git a/rust/cloud-storage/notification_db_client/.sqlx/query-2c284984a671b89d961837f824379a56da494f5687f5376a15c34fb442a260fb.json b/rust/cloud-storage/notification_db_client/.sqlx/query-2c284984a671b89d961837f824379a56da494f5687f5376a15c34fb442a260fb.json
deleted file mode 100644
index efa35a5daf..0000000000
--- a/rust/cloud-storage/notification_db_client/.sqlx/query-2c284984a671b89d961837f824379a56da494f5687f5376a15c34fb442a260fb.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n DELETE FROM user_device_registration\n WHERE device_endpoint = $1\n ",
- "describe": {
- "columns": [],
- "parameters": {
- "Left": [
- "Text"
- ]
- },
- "nullable": []
- },
- "hash": "2c284984a671b89d961837f824379a56da494f5687f5376a15c34fb442a260fb"
-}
diff --git a/rust/cloud-storage/notification_db_client/.sqlx/query-32bc3d9fd93e31e31e94a11d286017303907af0da309f50568bda9f6fa74c22f.json b/rust/cloud-storage/notification_db_client/.sqlx/query-32bc3d9fd93e31e31e94a11d286017303907af0da309f50568bda9f6fa74c22f.json
new file mode 100644
index 0000000000..4748f06d4d
--- /dev/null
+++ b/rust/cloud-storage/notification_db_client/.sqlx/query-32bc3d9fd93e31e31e94a11d286017303907af0da309f50568bda9f6fa74c22f.json
@@ -0,0 +1,23 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n INSERT INTO notification_email_unsubscribe_code (email, code) VALUES ($1, $2)\n ON CONFLICT (email) DO UPDATE \n SET code = notification_email_unsubscribe_code.code\n RETURNING notification_email_unsubscribe_code.code\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "code",
+ "type_info": "Uuid"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Text",
+ "Uuid"
+ ]
+ },
+ "nullable": [
+ false
+ ]
+ },
+ "hash": "32bc3d9fd93e31e31e94a11d286017303907af0da309f50568bda9f6fa74c22f"
+}
diff --git a/rust/cloud-storage/notification_db_client/.sqlx/query-2e2d524ba1930300b5c02fdba18fa4a3e72e7b493a259fe5d18b513d5c8addbd.json b/rust/cloud-storage/notification_db_client/.sqlx/query-3ad109bc298d98b88d0afac7d254a35a85f1671b808c2f2b71781114bbc1d134.json
similarity index 53%
rename from rust/cloud-storage/notification_db_client/.sqlx/query-2e2d524ba1930300b5c02fdba18fa4a3e72e7b493a259fe5d18b513d5c8addbd.json
rename to rust/cloud-storage/notification_db_client/.sqlx/query-3ad109bc298d98b88d0afac7d254a35a85f1671b808c2f2b71781114bbc1d134.json
index 8ff5cfd0ab..179c2f5674 100644
--- a/rust/cloud-storage/notification_db_client/.sqlx/query-2e2d524ba1930300b5c02fdba18fa4a3e72e7b493a259fe5d18b513d5c8addbd.json
+++ b/rust/cloud-storage/notification_db_client/.sqlx/query-3ad109bc298d98b88d0afac7d254a35a85f1671b808c2f2b71781114bbc1d134.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT d.device_endpoint\n FROM user_device_registration d\n WHERE d.device_token = $1\n LIMIT 1\n ",
+ "query": "\n SELECT d.device_endpoint\n FROM notification_user_device_registration d\n WHERE d.device_token = $1\n LIMIT 1\n ",
"describe": {
"columns": [
{
@@ -18,5 +18,5 @@
false
]
},
- "hash": "2e2d524ba1930300b5c02fdba18fa4a3e72e7b493a259fe5d18b513d5c8addbd"
+ "hash": "3ad109bc298d98b88d0afac7d254a35a85f1671b808c2f2b71781114bbc1d134"
}
diff --git a/rust/cloud-storage/notification_db_client/.sqlx/query-6c7eb689e2b36b5f9d73ebb66746c36ad70078feb62d295e33506f317fe07bb1.json b/rust/cloud-storage/notification_db_client/.sqlx/query-6c7eb689e2b36b5f9d73ebb66746c36ad70078feb62d295e33506f317fe07bb1.json
new file mode 100644
index 0000000000..4a2b3313e7
--- /dev/null
+++ b/rust/cloud-storage/notification_db_client/.sqlx/query-6c7eb689e2b36b5f9d73ebb66746c36ad70078feb62d295e33506f317fe07bb1.json
@@ -0,0 +1,14 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n DELETE FROM notification_user_device_registration\n WHERE device_endpoint = $1\n ",
+ "describe": {
+ "columns": [],
+ "parameters": {
+ "Left": [
+ "Text"
+ ]
+ },
+ "nullable": []
+ },
+ "hash": "6c7eb689e2b36b5f9d73ebb66746c36ad70078feb62d295e33506f317fe07bb1"
+}
diff --git a/rust/cloud-storage/notification_db_client/.sqlx/query-e9a54f1e44bd1247f8f8e48b88cb93c637bb5c1dfca3fae7d42aab6cc2238ed9.json b/rust/cloud-storage/notification_db_client/.sqlx/query-98923878d16c2d5d2594120fe481fdeb1b2ff97c69fe26b5a09c82d393ce4010.json
similarity index 55%
rename from rust/cloud-storage/notification_db_client/.sqlx/query-e9a54f1e44bd1247f8f8e48b88cb93c637bb5c1dfca3fae7d42aab6cc2238ed9.json
rename to rust/cloud-storage/notification_db_client/.sqlx/query-98923878d16c2d5d2594120fe481fdeb1b2ff97c69fe26b5a09c82d393ce4010.json
index a664ae02bd..d193eb4c34 100644
--- a/rust/cloud-storage/notification_db_client/.sqlx/query-e9a54f1e44bd1247f8f8e48b88cb93c637bb5c1dfca3fae7d42aab6cc2238ed9.json
+++ b/rust/cloud-storage/notification_db_client/.sqlx/query-98923878d16c2d5d2594120fe481fdeb1b2ff97c69fe26b5a09c82d393ce4010.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT d.device_endpoint\n FROM user_device_registration d\n WHERE d.user_id = $1\n ",
+ "query": "\n SELECT d.device_endpoint\n FROM notification_user_device_registration d\n WHERE d.user_id = $1\n ",
"describe": {
"columns": [
{
@@ -18,5 +18,5 @@
false
]
},
- "hash": "e9a54f1e44bd1247f8f8e48b88cb93c637bb5c1dfca3fae7d42aab6cc2238ed9"
+ "hash": "98923878d16c2d5d2594120fe481fdeb1b2ff97c69fe26b5a09c82d393ce4010"
}
diff --git a/rust/cloud-storage/notification_db_client/.sqlx/query-0182200e099205f7ee44e0f386afdd1dcc859021fbcda234ddab7b89f304f4ab.json b/rust/cloud-storage/notification_db_client/.sqlx/query-d185f3b4ca09c5a6372f6a64c4e6e5e12937814433dc5499b0dfdbe882c76192.json
similarity index 78%
rename from rust/cloud-storage/notification_db_client/.sqlx/query-0182200e099205f7ee44e0f386afdd1dcc859021fbcda234ddab7b89f304f4ab.json
rename to rust/cloud-storage/notification_db_client/.sqlx/query-d185f3b4ca09c5a6372f6a64c4e6e5e12937814433dc5499b0dfdbe882c76192.json
index 00c64194de..0b63e72e63 100644
--- a/rust/cloud-storage/notification_db_client/.sqlx/query-0182200e099205f7ee44e0f386afdd1dcc859021fbcda234ddab7b89f304f4ab.json
+++ b/rust/cloud-storage/notification_db_client/.sqlx/query-d185f3b4ca09c5a6372f6a64c4e6e5e12937814433dc5499b0dfdbe882c76192.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT d.device_endpoint,\n d.user_id,\n d.device_type as \"device_type: DeviceType\"\n FROM user_device_registration d\n WHERE d.user_id = ANY($1)\n ",
+ "query": "\n SELECT d.device_endpoint,\n d.user_id,\n d.device_type as \"device_type: DeviceType\"\n FROM notification_user_device_registration d\n WHERE d.user_id = ANY($1)\n ",
"describe": {
"columns": [
{
@@ -18,7 +18,7 @@
"name": "device_type: DeviceType",
"type_info": {
"Custom": {
- "name": "device_type_option",
+ "name": "notification_device_type_option",
"kind": {
"Enum": [
"ios",
@@ -40,5 +40,5 @@
false
]
},
- "hash": "0182200e099205f7ee44e0f386afdd1dcc859021fbcda234ddab7b89f304f4ab"
+ "hash": "d185f3b4ca09c5a6372f6a64c4e6e5e12937814433dc5499b0dfdbe882c76192"
}
diff --git a/rust/cloud-storage/notification_db_client/.sqlx/query-d5db55179b8f46b8788f1cc573b0734a33e800cd3fd990498c76c991b48931a8.json b/rust/cloud-storage/notification_db_client/.sqlx/query-d5db55179b8f46b8788f1cc573b0734a33e800cd3fd990498c76c991b48931a8.json
new file mode 100644
index 0000000000..bb751d673e
--- /dev/null
+++ b/rust/cloud-storage/notification_db_client/.sqlx/query-d5db55179b8f46b8788f1cc573b0734a33e800cd3fd990498c76c991b48931a8.json
@@ -0,0 +1,28 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n INSERT INTO notification_user_device_registration (id, user_id, device_token, device_endpoint, device_type)\n VALUES ($1, $2, $3, $4, $5)\n ON CONFLICT (device_endpoint) DO UPDATE SET user_id = $2, device_token = $3, device_type = $5, updated_at = NOW()\n ",
+ "describe": {
+ "columns": [],
+ "parameters": {
+ "Left": [
+ "Uuid",
+ "Text",
+ "Text",
+ "Text",
+ {
+ "Custom": {
+ "name": "notification_device_type_option",
+ "kind": {
+ "Enum": [
+ "ios",
+ "android"
+ ]
+ }
+ }
+ }
+ ]
+ },
+ "nullable": []
+ },
+ "hash": "d5db55179b8f46b8788f1cc573b0734a33e800cd3fd990498c76c991b48931a8"
+}
diff --git a/rust/cloud-storage/notification_db_client/Cargo.toml b/rust/cloud-storage/notification_db_client/Cargo.toml
index c15af209d2..370bd853b9 100644
--- a/rust/cloud-storage/notification_db_client/Cargo.toml
+++ b/rust/cloud-storage/notification_db_client/Cargo.toml
@@ -17,3 +17,6 @@ serde = { workspace = true }
sqlx = { workspace = true }
tracing = { workspace = true }
uuid = { workspace = true }
+
+[dev-dependencies]
+macro_db_migrator = { path = "../macro_db_migrator" }
diff --git a/rust/cloud-storage/notification_db_client/fixtures/user_devices.sql b/rust/cloud-storage/notification_db_client/fixtures/user_devices.sql
index 443077286a..f8796d4200 100644
--- a/rust/cloud-storage/notification_db_client/fixtures/user_devices.sql
+++ b/rust/cloud-storage/notification_db_client/fixtures/user_devices.sql
@@ -1,4 +1,4 @@
-INSERT INTO user_device_registration (
+INSERT INTO notification_user_device_registration (
id,
user_id,
device_token,
diff --git a/rust/cloud-storage/notification_db_client/justfile b/rust/cloud-storage/notification_db_client/justfile
index 655fcbd623..d5a52bc432 100644
--- a/rust/cloud-storage/notification_db_client/justfile
+++ b/rust/cloud-storage/notification_db_client/justfile
@@ -1,39 +1,6 @@
-DATABASE_URL := "postgres://user:password@localhost:5432/notificationdb"
+DATABASE_URL := "postgres://user:password@localhost:5432/macrodb"
mod sqlx '../sqlx.just'
-create_db:
- just sqlx::create_db {{ DATABASE_URL }}
-
-migrate_db:
- just sqlx::migrate_db {{ DATABASE_URL }}
-
prepare_db:
just sqlx::prepare_db {{ DATABASE_URL }}
-
-drop_db *FLAGS:
- just sqlx::drop_db {{ DATABASE_URL }} {{ FLAGS }}
-
-setup:
- just sqlx::setup {{ DATABASE_URL }}
-
-setup_prepare:
- just sqlx::setup_prepare {{ DATABASE_URL }}
-
-reset_db:
- just sqlx::reset_db {{ DATABASE_URL }}
-
-migrate_db_dev:
- DATABASE_URL=$(../scripts/rds_database_url.sh notification-db-dev notification-db-password-dev notificationdb) sqlx migrate run
-
-migrate_db_prod:
- #!/usr/bin/env bash
- echo -e "\033[31mWARNING: You are about to run migrations on the PRODUCTION database!\033[0m"
- echo -n "Are you sure you want to continue? [y/N] "
- read -r response
- if [[ "$response" =~ ^[Yy]$ ]]; then
- echo "Running production migrations..."
- DATABASE_URL=$(../scripts/rds_database_url.sh notification-db-prod notification-db-password-prod notificationdb) sqlx migrate run
- else
- echo "Migration cancelled."
- fi
diff --git a/rust/cloud-storage/notification_db_client/migrations/20241209172327_schema.sql b/rust/cloud-storage/notification_db_client/migrations/20241209172327_schema.sql
deleted file mode 100644
index 959ec04ea6..0000000000
--- a/rust/cloud-storage/notification_db_client/migrations/20241209172327_schema.sql
+++ /dev/null
@@ -1,44 +0,0 @@
-CREATE TABLE notification (
- id UUID PRIMARY KEY NOT NULL, -- id of notification, self-generated UUIDv7
- notification_event_type VARCHAR(255) NOT NULL, -- the type of notification that this event generates
- event_item_id TEXT NOT NULL, -- id of the relevant item that is triggering the notification
- event_item_type TEXT NOT NULL, -- type of the relevant item that is triggering the notification
- service_sender TEXT NOT NULL, -- what service generated the notification
- created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- time notification was created
- metadata JSONB -- any custom metadata that may be needed for the notification
-);
-
-CREATE TABLE user_notification (
- user_id TEXT NOT NULL, -- user id
- notification_id UUID NOT NULL REFERENCES notification (id) ON DELETE CASCADE, -- notification id
- created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- time user notification was created
- sent BOOLEAN NOT NULL DEFAULT FALSE, -- whether the notification has been sent
- seen_at TIMESTAMP, -- time the notification was seen
- deleted_at TIMESTAMP, -- time the notification was deleted
- PRIMARY KEY (user_id, notification_id)
-);
-
-CREATE TYPE notification_preference_option as ENUM ('none', 'dot', 'ping');
-
-CREATE TABLE notification_preference (
- item_id TEXT NOT NULL, -- id of item that the preference is for
- item_type TEXT NOT NULL, -- type of item (document | chat | etc...)
- user_id TEXT NOT NULL, -- user id
- notification_type notification_preference_option NOT NULL, -- type of preference
- created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- time preference was created
- updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- time preference was updated
- PRIMARY KEY (item_id, item_type, user_id)
-);
-
--- Index on event_item_id and event_item_type to get notifications per event
-CREATE INDEX idx_notification_event ON notification (event_item_id, event_item_type);
-
--- Index user id to get notifications per user
-CREATE INDEX idx_user_notification_user ON user_notification (user_id);
-
--- Index user id to get user notifications per notification id
-CREATE INDEX idx_user_notification_notification ON user_notification (notification_id);
-
-CREATE INDEX idx_notification_preference_user ON notification_preference (user_id);
-
-CREATE INDEX idx_notification_preference_item ON notification_preference (item_id, item_type);
diff --git a/rust/cloud-storage/notification_db_client/migrations/20250116180223_user_notification_done.sql b/rust/cloud-storage/notification_db_client/migrations/20250116180223_user_notification_done.sql
deleted file mode 100644
index 042b20c863..0000000000
--- a/rust/cloud-storage/notification_db_client/migrations/20250116180223_user_notification_done.sql
+++ /dev/null
@@ -1,2 +0,0 @@
--- Add a done column to user_notification
-ALTER TABLE user_notification ADD COLUMN done BOOLEAN NOT NULL DEFAULT FALSE;
diff --git a/rust/cloud-storage/notification_db_client/migrations/20250206043507_add_notifications_sender_id_column.sql b/rust/cloud-storage/notification_db_client/migrations/20250206043507_add_notifications_sender_id_column.sql
deleted file mode 100644
index 04d62310f3..0000000000
--- a/rust/cloud-storage/notification_db_client/migrations/20250206043507_add_notifications_sender_id_column.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE notification ADD COLUMN sender_id TEXT;
diff --git a/rust/cloud-storage/notification_db_client/migrations/20250207023720_remove_event_item_type_from_index.sql b/rust/cloud-storage/notification_db_client/migrations/20250207023720_remove_event_item_type_from_index.sql
deleted file mode 100644
index 00d6dd289d..0000000000
--- a/rust/cloud-storage/notification_db_client/migrations/20250207023720_remove_event_item_type_from_index.sql
+++ /dev/null
@@ -1,4 +0,0 @@
--- Remove event_item_type from index on notification
-DROP INDEX IF EXISTS idx_notification_event;
-
-CREATE INDEX idx_notification_event ON notification (event_item_id);
diff --git a/rust/cloud-storage/notification_db_client/migrations/20250218153539_user_notification_unsubscribe_preferences.sql b/rust/cloud-storage/notification_db_client/migrations/20250218153539_user_notification_unsubscribe_preferences.sql
deleted file mode 100644
index 5219ed5bdc..0000000000
--- a/rust/cloud-storage/notification_db_client/migrations/20250218153539_user_notification_unsubscribe_preferences.sql
+++ /dev/null
@@ -1,35 +0,0 @@
--- Table to store all email addresses that have unsubscribed from notifications
--- Eventually this may expand to support a more complex unsubscribe model
-CREATE TABLE notification_email_unsubscribe (
- email TEXT PRIMARY KEY
-);
-
-CREATE TABLE user_notification_item_unsubscribe (
- user_id TEXT NOT NULL,
- item_id TEXT NOT NULL,
- item_type TEXT NOT NULL,
- PRIMARY KEY (user_id, item_id)
-);
-
--- Get by user_id
-CREATE INDEX idx_user_notification_item_unsubscribe_user_id ON user_notification_item_unsubscribe (user_id);
-
--- Get by item_id
-CREATE INDEX idx_user_notification_item_unsubscribe_item_id ON user_notification_item_unsubscribe (item_id);
-
-
-CREATE TABLE user_notification_item_event_unsubscribe (
- user_id TEXT NOT NULL,
- item_id TEXT NOT NULL,
- item_type TEXT NOT NULL,
- notification_event_type TEXT NOT NULL,
- PRIMARY KEY (user_id, item_id, notification_event_type)
-);
-
--- Get by user_id
-CREATE INDEX idx_user_notification_item_event_unsubscribe_user_id ON user_notification_item_event_unsubscribe (user_id);
-
--- Get by item_id
-CREATE INDEX idx_user_notification_item_event_unsubscribe_item_id ON user_notification_item_event_unsubscribe (item_id);
-
-CREATE INDEX idx_user_notification_item_event_unsubscribe_item_id_notification_event_type ON user_notification_item_event_unsubscribe (item_id, notification_event_type);
diff --git a/rust/cloud-storage/notification_db_client/migrations/20250218202729_email_unsubscribe_code.sql b/rust/cloud-storage/notification_db_client/migrations/20250218202729_email_unsubscribe_code.sql
deleted file mode 100644
index 691abd49ee..0000000000
--- a/rust/cloud-storage/notification_db_client/migrations/20250218202729_email_unsubscribe_code.sql
+++ /dev/null
@@ -1,6 +0,0 @@
-CREATE TABLE email_unsubscribe_code (
- email TEXT PRIMARY KEY, -- The email address should be lowercased before insertion
- code UUID UNIQUE NOT NULL -- UUID used in the email unsubscribe link
-);
-
-CREATE UNIQUE INDEX email_unsubscribe_code_code_idx ON email_unsubscribe_code (code);
diff --git a/rust/cloud-storage/notification_db_client/migrations/20250228020635_user_device_registration.sql b/rust/cloud-storage/notification_db_client/migrations/20250228020635_user_device_registration.sql
deleted file mode 100644
index 4625837802..0000000000
--- a/rust/cloud-storage/notification_db_client/migrations/20250228020635_user_device_registration.sql
+++ /dev/null
@@ -1,16 +0,0 @@
-CREATE TYPE device_type_option as ENUM ('ios', 'android');
-
-CREATE TABLE user_device_registration (
- id UUID PRIMARY KEY NOT NULL, -- registration id, self-generated UUIDv7
- user_id TEXT NOT NULL, -- user associated with the device
- device_token TEXT NOT NULL, -- device-app combo from registering with a Push Notification Service
- device_endpoint TEXT UNIQUE NOT NULL, -- push notification endpoint, must be unique; index is auto-created
- device_type device_type_option NOT NULL, -- type of device (ios | android)
- created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- time registration was created
- updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- time endpoint was updated
- last_used_at TIMESTAMP -- time endpoint was last used to send a notification
-);
-
-CREATE INDEX idx_user_device_registration_user ON user_device_registration (user_id);
-
-CREATE INDEX idx_user_device_registration_device_token ON user_device_registration (device_token);
diff --git a/rust/cloud-storage/notification_db_client/migrations/20250321144400_add_channel_notification_email_sent.sql b/rust/cloud-storage/notification_db_client/migrations/20250321144400_add_channel_notification_email_sent.sql
deleted file mode 100644
index 3e629197bf..0000000000
--- a/rust/cloud-storage/notification_db_client/migrations/20250321144400_add_channel_notification_email_sent.sql
+++ /dev/null
@@ -1,11 +0,0 @@
--- Creates channel_notification_email_sent table
-CREATE TABLE channel_notification_email_sent (
- channel_id UUID NOT NULL, -- the id of the channel
- user_id TEXT NOT NULL, -- the id of the user
- created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
- updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
- PRIMARY KEY (channel_id, user_id) -- composite primary key
-);
-
-CREATE INDEX idx_channel_notification_email_sent_channel ON channel_notification_email_sent (channel_id);
-CREATE INDEX idx_channel_notification_email_sent_user ON channel_notification_email_sent (user_id);
diff --git a/rust/cloud-storage/notification_db_client/migrations/20250403182036_remove_unused_notification_preferences.sql b/rust/cloud-storage/notification_db_client/migrations/20250403182036_remove_unused_notification_preferences.sql
deleted file mode 100644
index 41dd60df0f..0000000000
--- a/rust/cloud-storage/notification_db_client/migrations/20250403182036_remove_unused_notification_preferences.sql
+++ /dev/null
@@ -1,2 +0,0 @@
-DROP TABLE notification_preference;
-DROP TYPE notification_preference_option;
diff --git a/rust/cloud-storage/notification_db_client/migrations/20250403182352_mute_notification_table.sql b/rust/cloud-storage/notification_db_client/migrations/20250403182352_mute_notification_table.sql
deleted file mode 100644
index df1cd2a575..0000000000
--- a/rust/cloud-storage/notification_db_client/migrations/20250403182352_mute_notification_table.sql
+++ /dev/null
@@ -1,4 +0,0 @@
--- Add migration script here
-CREATE TABLE user_mute_notification (
- user_id TEXT PRIMARY KEY -- the user who has muted notifications
-);
diff --git a/rust/cloud-storage/notification_db_client/migrations/20250403185553_remove_user_notification_item_event_unsubscribe.sql b/rust/cloud-storage/notification_db_client/migrations/20250403185553_remove_user_notification_item_event_unsubscribe.sql
deleted file mode 100644
index 4590db80eb..0000000000
--- a/rust/cloud-storage/notification_db_client/migrations/20250403185553_remove_user_notification_item_event_unsubscribe.sql
+++ /dev/null
@@ -1,2 +0,0 @@
--- Add migration script here
-DROP TABLE user_notification_item_event_unsubscribe;
diff --git a/rust/cloud-storage/notification_db_client/migrations/20250513190044_remove_channel_notification_email_sent_updated_at.sql b/rust/cloud-storage/notification_db_client/migrations/20250513190044_remove_channel_notification_email_sent_updated_at.sql
deleted file mode 100644
index 24b26c0685..0000000000
--- a/rust/cloud-storage/notification_db_client/migrations/20250513190044_remove_channel_notification_email_sent_updated_at.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE channel_notification_email_sent DROP COLUMN updated_at;
diff --git a/rust/cloud-storage/notification_db_client/migrations/20250520170011_notification_event_item_type_index.sql b/rust/cloud-storage/notification_db_client/migrations/20250520170011_notification_event_item_type_index.sql
deleted file mode 100644
index bb30ab8756..0000000000
--- a/rust/cloud-storage/notification_db_client/migrations/20250520170011_notification_event_item_type_index.sql
+++ /dev/null
@@ -1,2 +0,0 @@
--- Add migration script here
-CREATE INDEX idx_notification_event_item_type ON notification (event_item_type);
diff --git a/rust/cloud-storage/notification_db_client/migrations/20250521151925_notification_email_sent_table.sql b/rust/cloud-storage/notification_db_client/migrations/20250521151925_notification_email_sent_table.sql
deleted file mode 100644
index dcb38d20c0..0000000000
--- a/rust/cloud-storage/notification_db_client/migrations/20250521151925_notification_email_sent_table.sql
+++ /dev/null
@@ -1,5 +0,0 @@
--- Create notification_email_sent table
-CREATE TABLE notification_email_sent (
- user_id TEXT PRIMARY KEY NOT NULL, -- the id of the user
- sent_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
-);
diff --git a/rust/cloud-storage/notification_db_client/migrations/20250903173644_is_important_v0_column.sql b/rust/cloud-storage/notification_db_client/migrations/20250903173644_is_important_v0_column.sql
deleted file mode 100644
index 501faf0d75..0000000000
--- a/rust/cloud-storage/notification_db_client/migrations/20250903173644_is_important_v0_column.sql
+++ /dev/null
@@ -1,2 +0,0 @@
-ALTER TABLE user_notification
- ADD COLUMN is_important_v0 BOOLEAN NOT NULL DEFAULT FALSE;
\ No newline at end of file
diff --git a/rust/cloud-storage/notification_db_client/migrations/20251002232026_migrate_invalid_event_item_type.sql b/rust/cloud-storage/notification_db_client/migrations/20251002232026_migrate_invalid_event_item_type.sql
deleted file mode 100644
index 11b5e489d9..0000000000
--- a/rust/cloud-storage/notification_db_client/migrations/20251002232026_migrate_invalid_event_item_type.sql
+++ /dev/null
@@ -1,37 +0,0 @@
--- Add migration script here
--- Migration to update non-EntityType enumerated event_item_type values to 'document'
--- Valid EntityType values: user, chat, channel, document, project, email, team
-
-BEGIN;
-
-CREATE TEMP TABLE invalid_event_item_types AS
-SELECT DISTINCT event_item_type
-FROM notification
-WHERE event_item_type NOT IN ('user', 'chat', 'channel', 'document', 'project', 'email', 'team');
-
-DO $$
-DECLARE
- rec RECORD;
-BEGIN
- FOR rec IN SELECT * FROM invalid_event_item_types
- LOOP
- RAISE NOTICE 'Will update event_item_type: % to document', rec.event_item_type;
- END LOOP;
-END $$;
-
-UPDATE notification
-SET event_item_type = 'document'
-WHERE event_item_type NOT IN ('user', 'chat', 'channel', 'document', 'project', 'email', 'team');
-
-UPDATE notification
-SET metadata = jsonb_set(
- metadata,
- '{itemType}',
- '"document"'::jsonb
-)
-WHERE metadata ? 'itemType'
- AND metadata->>'itemType' NOT IN ('user', 'chat', 'channel', 'document', 'project', 'email', 'team');
-
-DROP TABLE invalid_event_item_types;
-
-COMMIT;
diff --git a/rust/cloud-storage/notification_db_client/migrations/20260105154225_add_apns_collapse_key.sql b/rust/cloud-storage/notification_db_client/migrations/20260105154225_add_apns_collapse_key.sql
deleted file mode 100644
index 991681c793..0000000000
--- a/rust/cloud-storage/notification_db_client/migrations/20260105154225_add_apns_collapse_key.sql
+++ /dev/null
@@ -1,4 +0,0 @@
--- Add apns_collapse_key column to notification table for iOS push notification management.
--- This allows each notification to have a unique collapse key, enabling notifications
--- to stack in the notification center while still being individually clearable.
-ALTER TABLE notification ADD COLUMN apns_collapse_key TEXT;
diff --git a/rust/cloud-storage/notification_db_client/src/channel_notification_email_sent/get.rs b/rust/cloud-storage/notification_db_client/src/channel_notification_email_sent/get.rs
index ca5c33a0d0..c93e922608 100644
--- a/rust/cloud-storage/notification_db_client/src/channel_notification_email_sent/get.rs
+++ b/rust/cloud-storage/notification_db_client/src/channel_notification_email_sent/get.rs
@@ -78,9 +78,13 @@ pub async fn get_channel_notification_email_sent_bulk_by_channel_ids(
#[cfg(test)]
mod tests {
use super::*;
+ use macro_db_migrator::MACRO_DB_MIGRATIONS;
use sqlx::{Pool, Postgres};
- #[sqlx::test(fixtures(path = "../../fixtures", scripts("channel_notification_email_sent")))]
+ #[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../fixtures", scripts("channel_notification_email_sent"))
+ )]
async fn test_get_channel_notification_email_sent_bulk(
pool: Pool<Postgres>,
) -> anyhow::Result<()> {
diff --git a/rust/cloud-storage/notification_db_client/src/channel_notification_email_sent/upsert.rs b/rust/cloud-storage/notification_db_client/src/channel_notification_email_sent/upsert.rs
index bc285c7577..04ac0e44c3 100644
--- a/rust/cloud-storage/notification_db_client/src/channel_notification_email_sent/upsert.rs
+++ b/rust/cloud-storage/notification_db_client/src/channel_notification_email_sent/upsert.rs
@@ -62,9 +62,13 @@ pub async fn upsert_channel_notification_email_sent_bulk_channel_ids(
#[cfg(test)]
mod tests {
use super::*;
+ use macro_db_migrator::MACRO_DB_MIGRATIONS;
use sqlx::{Pool, Postgres};
- #[sqlx::test(fixtures(path = "../../fixtures", scripts("channel_notification_email_sent")))]
+ #[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../fixtures", scripts("channel_notification_email_sent"))
+ )]
async fn test_upsert_channel_notification_email_sent_bulk(
pool: Pool<Postgres>,
) -> anyhow::Result<()> {
diff --git a/rust/cloud-storage/notification_db_client/src/device/mod.rs b/rust/cloud-storage/notification_db_client/src/device/mod.rs
index 0538084fcc..979b0863b2 100644
--- a/rust/cloud-storage/notification_db_client/src/device/mod.rs
+++ b/rust/cloud-storage/notification_db_client/src/device/mod.rs
@@ -11,7 +11,7 @@ pub async fn get_device_endpoint(
let result = sqlx::query!(
r#"
SELECT d.device_endpoint
- FROM user_device_registration d
+ FROM notification_user_device_registration d
WHERE d.device_token = $1
LIMIT 1
"#,
@@ -36,7 +36,7 @@ pub async fn upsert_user_device(
let id = macro_uuid::generate_uuid_v7();
sqlx::query!(
r#"
- INSERT INTO user_device_registration (id, user_id, device_token, device_endpoint, device_type)
+ INSERT INTO notification_user_device_registration (id, user_id, device_token, device_endpoint, device_type)
VALUES ($1, $2, $3, $4, $5)
ON CONFLICT (device_endpoint) DO UPDATE SET user_id = $2, device_token = $3, device_type = $5, updated_at = NOW()
"#,
@@ -72,7 +72,7 @@ pub async fn get_users_device_endpoints(
SELECT d.device_endpoint,
d.user_id,
d.device_type as "device_type: DeviceType"
- FROM user_device_registration d
+ FROM notification_user_device_registration d
WHERE d.user_id = ANY($1)
"#,
ids.as_slice()
@@ -103,7 +103,7 @@ pub async fn get_user_device_endpoints(
let result: Vec<String> = sqlx::query!(
r#"
SELECT d.device_endpoint
- FROM user_device_registration d
+ FROM notification_user_device_registration d
WHERE d.user_id = $1
"#,
user_id
@@ -124,7 +124,7 @@ pub async fn delete_user_device_token(
) -> anyhow::Result<String> {
let result = sqlx::query!(
r#"
- DELETE FROM user_device_registration
+ DELETE FROM notification_user_device_registration
WHERE device_token = $1 AND device_type = $2
RETURNING device_endpoint
"#,
@@ -144,7 +144,7 @@ pub async fn delete_user_device_by_endpoint(
) -> anyhow::Result<()> {
sqlx::query!(
r#"
- DELETE FROM user_device_registration
+ DELETE FROM notification_user_device_registration
WHERE device_endpoint = $1
"#,
device_endpoint
@@ -158,9 +158,10 @@ pub async fn delete_user_device_by_endpoint(
#[cfg(test)]
mod tests {
use super::*;
+ use macro_db_migrator::MACRO_DB_MIGRATIONS;
use sqlx::{Pool, Postgres};
- #[sqlx::test]
+ #[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
async fn test_upsert_new_user_device(pool: Pool<Postgres>) -> anyhow::Result<()> {
let user_id = "macro|[email protected]";
let device_token = "test_token_47295";
@@ -172,7 +173,7 @@ mod tests {
let result = sqlx::query!(
r#"
SELECT id, user_id, device_token, device_endpoint, device_type as "device_type:DeviceType"
- FROM user_device_registration
+ FROM notification_user_device_registration
WHERE device_endpoint = $1
"#,
device_endpoint
@@ -187,13 +188,16 @@ mod tests {
Ok(())
}
- #[sqlx::test(fixtures(path = "../../fixtures", scripts("user_devices")))]
+ #[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../fixtures", scripts("user_devices"))
+ )]
async fn test_upsert_existing_user_device(pool: Pool<Postgres>) -> anyhow::Result<()> {
let new_token = "new_token_123";
let result = sqlx::query!(
r#"
SELECT id, user_id, device_token, device_endpoint, device_type as "device_type:DeviceType"
- FROM user_device_registration
+ FROM notification_user_device_registration
WHERE id = '017d85a8-c7c6-7c40-b4f3-a6c1b3c0d1e2'
"#
)
@@ -219,7 +223,7 @@ mod tests {
let result = sqlx::query!(
r#"
SELECT id, user_id, device_token, device_endpoint, device_type as "device_type:DeviceType"
- FROM user_device_registration
+ FROM notification_user_device_registration
WHERE id = '017d85a8-c7c6-7c40-b4f3-a6c1b3c0d1e2'
"#
)
@@ -230,12 +234,15 @@ mod tests {
Ok(())
}
- #[sqlx::test(fixtures(path = "../../fixtures", scripts("user_devices")))]
+ #[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../fixtures", scripts("user_devices"))
+ )]
async fn test_delete_user_device(pool: Pool<Postgres>) -> anyhow::Result<()> {
let result = sqlx::query!(
r#"
SELECT id, user_id, device_token, device_endpoint, device_type as "device_type:DeviceType"
- FROM user_device_registration
+ FROM notification_user_device_registration
WHERE id = '017d85a8-c7c6-7c40-b4f3-a6c1b3c0d1e4'
"#
)
@@ -254,7 +261,7 @@ mod tests {
let result = sqlx::query!(
r#"
SELECT id, user_id, device_token, device_endpoint, device_type as "device_type:DeviceType"
- FROM user_device_registration
+ FROM notification_user_device_registration
WHERE device_token = $1 AND device_type = $2
"#,
result.as_ref().unwrap().device_token,
diff --git a/rust/cloud-storage/notification_db_client/src/email_unsubscribe_code.rs b/rust/cloud-storage/notification_db_client/src/email_unsubscribe_code.rs
index e4d7d757e0..e4657fa0d7 100644
--- a/rust/cloud-storage/notification_db_client/src/email_unsubscribe_code.rs
+++ b/rust/cloud-storage/notification_db_client/src/email_unsubscribe_code.rs
@@ -1,18 +1,18 @@
-/// Upserts the given email/code into the email_unsubscribe_code table
+/// Upserts the given email/code into the notification_email_unsubscribe_code table
/// This will forcefully set the email to be lowercased before insertion
/// Returns the code that was generated
#[tracing::instrument(skip(db))]
-pub async fn upsert_email_unsubscribe_code(
+pub async fn upsert_notification_email_unsubscribe_code(
db: &sqlx::Pool<sqlx::Postgres>,
email: &str,
) -> anyhow::Result<String> {
let code = macro_uuid::generate_uuid_v7();
let code = sqlx::query!(
r#"
- INSERT INTO email_unsubscribe_code (email, code) VALUES ($1, $2)
+ INSERT INTO notification_email_unsubscribe_code (email, code) VALUES ($1, $2)
ON CONFLICT (email) DO UPDATE
- SET code = email_unsubscribe_code.code
- RETURNING email_unsubscribe_code.code
+ SET code = notification_email_unsubscribe_code.code
+ RETURNING notification_email_unsubscribe_code.code
"#,
email.to_lowercase(),
code
@@ -32,7 +32,7 @@ pub async fn get_email_by_code(
) -> anyhow::Result<Option<String>> {
let email = sqlx::query!(
r#"
- SELECT email FROM email_unsubscribe_code WHERE code = $1
+ SELECT email FROM notification_email_unsubscribe_code WHERE code = $1
"#,
macro_uuid::string_to_uuid(code)?
)
@@ -46,16 +46,17 @@ pub async fn get_email_by_code(
#[cfg(test)]
mod tests {
use super::*;
+ use macro_db_migrator::MACRO_DB_MIGRATIONS;
- #[sqlx::test]
- async fn test_upsert_email_unsubscribe_code(
+ #[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+ async fn test_upsert_notification_email_unsubscribe_code(
pool: sqlx::Pool<sqlx::Postgres>,
) -> anyhow::Result<()> {
let code = macro_uuid::generate_uuid_v7();
sqlx::query!(
r#"
- INSERT INTO email_unsubscribe_code(email, code)
+ INSERT INTO notification_email_unsubscribe_code(email, code)
VALUES ($1, $2)
"#,
"a",
@@ -64,24 +65,24 @@ mod tests {
.execute(&pool)
.await?;
- let result = upsert_email_unsubscribe_code(&pool, "A").await?;
+ let result = upsert_notification_email_unsubscribe_code(&pool, "A").await?;
assert_eq!(result, code.to_string());
- let result = upsert_email_unsubscribe_code(&pool, "b").await?;
+ let result = upsert_notification_email_unsubscribe_code(&pool, "b").await?;
assert_ne!(result, code.to_string());
Ok(())
}
- #[sqlx::test]
+ #[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
async fn test_get_email_by_code(pool: sqlx::Pool<sqlx::Postgres>) -> anyhow::Result<()> {
let code = macro_uuid::generate_uuid_v7();
sqlx::query!(
r#"
- INSERT INTO email_unsubscribe_code(email, code)
+ INSERT INTO notification_email_unsubscribe_code(email, code)
VALUES ($1, $2)
"#,
"a",
diff --git a/rust/cloud-storage/notification_db_client/src/notification/create.rs b/rust/cloud-storage/notification_db_client/src/notification/create.rs
index 55decde2c2..8f9bc6d003 100644
--- a/rust/cloud-storage/notification_db_client/src/notification/create.rs
+++ b/rust/cloud-storage/notification_db_client/src/notification/create.rs
@@ -77,11 +77,12 @@ pub async fn create_notification_transaction(
#[cfg(test)]
mod tests {
use super::*;
+ use macro_db_migrator::MACRO_DB_MIGRATIONS;
use model_entity::EntityType;
use model_notifications::NotificationEventType;
use sqlx::{Pool, Postgres};
- #[sqlx::test]
+ #[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
async fn test_create_notification(pool: Pool<Postgres>) -> anyhow::Result<()> {
let uuid = macro_uuid::generate_uuid_v7();
let notification = RawNotification {
@@ -101,7 +102,7 @@ mod tests {
Ok(())
}
- #[sqlx::test]
+ #[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
async fn test_create_notification_transaction(pool: Pool<Postgres>) -> anyhow::Result<()> {
let uuid = macro_uuid::generate_uuid_v7();
let notification = RawNotification {
diff --git a/rust/cloud-storage/notification_db_client/src/notification/get/tests.rs b/rust/cloud-storage/notification_db_client/src/notification/get/tests.rs
index 41d86a8ae2..b4e0c30918 100644
--- a/rust/cloud-storage/notification_db_client/src/notification/get/tests.rs
+++ b/rust/cloud-storage/notification_db_client/src/notification/get/tests.rs
@@ -1,7 +1,11 @@
use super::*;
+use macro_db_migrator::MACRO_DB_MIGRATIONS;
use sqlx::{Pool, Postgres};
-#[sqlx::test(fixtures(path = "../../../fixtures", scripts("basic_notification")))]
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("basic_notification"))
+)]
async fn test_get_basic_notification(pool: Pool<Postgres>) -> anyhow::Result<()> {
let notification_id = macro_uuid::string_to_uuid("0193b1ea-a542-7589-893b-2b4a509c1e76")?;
@@ -15,7 +19,10 @@ async fn test_get_basic_notification(pool: Pool<Postgres>) -> anyhow::Result<()>
Ok(())
}
-#[sqlx::test(fixtures(path = "../../../fixtures", scripts("basic_notification")))]
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("basic_notification"))
+)]
async fn test_update_basic_notification(pool: Pool<Postgres>) -> anyhow::Result<()> {
let notification_id = macro_uuid::string_to_uuid("0193b1ea-a542-7589-893b-2b4a509c1e76")?;
let collapse_key = "test-collapse-key";
diff --git a/rust/cloud-storage/notification_db_client/src/unsubscribe/email.rs b/rust/cloud-storage/notification_db_client/src/unsubscribe/email.rs
index c058fa7f73..a4bb829c6e 100644
--- a/rust/cloud-storage/notification_db_client/src/unsubscribe/email.rs
+++ b/rust/cloud-storage/notification_db_client/src/unsubscribe/email.rs
@@ -62,7 +62,12 @@ pub async fn remove_email_unsubscribe(
#[cfg(test)]
mod tests {
use super::*;
- #[sqlx::test(fixtures(path = "../../fixtures", scripts("email_unsubscribe_list")))]
+ use macro_db_migrator::MACRO_DB_MIGRATIONS;
+
+ #[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../fixtures", scripts("email_unsubscribe_list"))
+ )]
async fn test_is_email_unsubscribed_batch(
pool: sqlx::Pool<sqlx::Postgres>,
) -> anyhow::Result<()> {
@@ -89,7 +94,10 @@ mod tests {
Ok(())
}
- #[sqlx::test(fixtures(path = "../../fixtures", scripts("email_unsubscribe_list")))]
+ #[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../fixtures", scripts("email_unsubscribe_list"))
+ )]
async fn test_upsert_email_unsubscribe(pool: sqlx::Pool<sqlx::Postgres>) -> anyhow::Result<()> {
upsert_email_unsubscribe(&pool, "A").await?;
upsert_email_unsubscribe(&pool, "NeW").await?;
@@ -106,7 +114,10 @@ mod tests {
Ok(())
}
- #[sqlx::test(fixtures(path = "../../fixtures", scripts("email_unsubscribe_list")))]
+ #[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../fixtures", scripts("email_unsubscribe_list"))
+ )]
async fn test_remove_email_unsubscribe(pool: sqlx::Pool<sqlx::Postgres>) -> anyhow::Result<()> {
remove_email_unsubscribe(&pool, "A").await?;
let result = sqlx::query!(
diff --git a/rust/cloud-storage/notification_db_client/src/unsubscribe/get.rs b/rust/cloud-storage/notification_db_client/src/unsubscribe/get.rs
index 0f1631c3b5..645a64c062 100644
--- a/rust/cloud-storage/notification_db_client/src/unsubscribe/get.rs
+++ b/rust/cloud-storage/notification_db_client/src/unsubscribe/get.rs
@@ -32,9 +32,13 @@ pub async fn get_user_unsubscribes(
#[cfg(test)]
mod tests {
use super::*;
+ use macro_db_migrator::MACRO_DB_MIGRATIONS;
use sqlx::{Pool, Postgres};
- #[sqlx::test(fixtures(path = "../../fixtures", scripts("user_unsubscribes")))]
+ #[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../fixtures", scripts("user_unsubscribes"))
+ )]
async fn test_get_user_unsubscribes(pool: Pool<Postgres>) {
let result = get_user_unsubscribes(&pool, "no-user").await.unwrap();
assert_eq!(result.len(), 0);
diff --git a/rust/cloud-storage/notification_db_client/src/unsubscribe/item.rs b/rust/cloud-storage/notification_db_client/src/unsubscribe/item.rs
index 8a7eef67f5..99c87fbc6b 100644
--- a/rust/cloud-storage/notification_db_client/src/unsubscribe/item.rs
+++ b/rust/cloud-storage/notification_db_client/src/unsubscribe/item.rs
@@ -67,7 +67,12 @@ pub async fn remove_unsubscribed_item_user(
#[cfg(test)]
mod tests {
use super::*;
- #[sqlx::test(fixtures(path = "../../fixtures", scripts("user_unsubscribed_item")))]
+ use macro_db_migrator::MACRO_DB_MIGRATIONS;
+
+ #[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../fixtures", scripts("user_unsubscribed_item"))
+ )]
async fn test_get_unsubscribed_item_users(
pool: sqlx::Pool<sqlx::Postgres>,
) -> anyhow::Result<()> {
@@ -84,7 +89,10 @@ mod tests {
Ok(())
}
- #[sqlx::test(fixtures(path = "../../fixtures", scripts("user_unsubscribed_item")))]
+ #[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../fixtures", scripts("user_unsubscribed_item"))
+ )]
async fn test_upsert_unsubscribed_item_user(
pool: sqlx::Pool<sqlx::Postgres>,
) -> anyhow::Result<()> {
@@ -104,7 +112,10 @@ mod tests {
Ok(())
}
- #[sqlx::test(fixtures(path = "../../fixtures", scripts("user_unsubscribed_item")))]
+ #[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../fixtures", scripts("user_unsubscribed_item"))
+ )]
async fn test_remove_unsubscribed_item_user(
pool: sqlx::Pool<sqlx::Postgres>,
) -> anyhow::Result<()> {
diff --git a/rust/cloud-storage/notification_db_client/src/user_mute_notification.rs b/rust/cloud-storage/notification_db_client/src/user_mute_notification.rs
index d792659acc..48667b29e8 100644
--- a/rust/cloud-storage/notification_db_client/src/user_mute_notification.rs
+++ b/rust/cloud-storage/notification_db_client/src/user_mute_notification.rs
@@ -60,8 +60,9 @@ pub async fn get_user_mute_notification_bulk(
#[cfg(test)]
mod tests {
use super::*;
+ use macro_db_migrator::MACRO_DB_MIGRATIONS;
- #[sqlx::test]
+ #[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
async fn test_upsert_user_mute_notification(
pool: sqlx::Pool<sqlx::Postgres>,
) -> anyhow::Result<()> {
@@ -80,7 +81,7 @@ mod tests {
Ok(())
}
- #[sqlx::test]
+ #[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
async fn test_get_user_mute_notification_bulk(
pool: sqlx::Pool<sqlx::Postgres>,
) -> anyhow::Result<()> {
diff --git a/rust/cloud-storage/notification_db_client/src/user_notification/create.rs b/rust/cloud-storage/notification_db_client/src/user_notification/create.rs
index 0d37f2486f..f47990afda 100644
--- a/rust/cloud-storage/notification_db_client/src/user_notification/create.rs
+++ b/rust/cloud-storage/notification_db_client/src/user_notification/create.rs
@@ -25,9 +25,13 @@ pub async fn create_bulk_user_notifications(
#[cfg(test)]
mod tests {
use super::*;
+ use macro_db_migrator::MACRO_DB_MIGRATIONS;
use sqlx::{Pool, Postgres};
- #[sqlx::test(fixtures(path = "../../fixtures", scripts("user_notifications")))]
+ #[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../fixtures", scripts("user_notifications"))
+ )]
async fn test_create_bulk_user_notifications(pool: Pool<Postgres>) -> anyhow::Result<()> {
let mut transaction = pool.begin().await?;
create_bulk_user_notifications(
diff --git a/rust/cloud-storage/notification_db_client/src/user_notification/delete/test.rs b/rust/cloud-storage/notification_db_client/src/user_notification/delete/test.rs
index 45b45f9b2b..a13c3bebd8 100644
--- a/rust/cloud-storage/notification_db_client/src/user_notification/delete/test.rs
+++ b/rust/cloud-storage/notification_db_client/src/user_notification/delete/test.rs
@@ -1,7 +1,11 @@
use super::*;
+use macro_db_migrator::MACRO_DB_MIGRATIONS;
use sqlx::{Pool, Postgres};
-#[sqlx::test(fixtures(path = "../../../fixtures", scripts("user_notifications")))]
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("user_notifications"))
+)]
async fn test_delete_user_notification(pool: Pool<Postgres>) -> anyhow::Result<()> {
delete_user_notification(
&pool,
@@ -13,7 +17,10 @@ async fn test_delete_user_notification(pool: Pool<Postgres>) -> anyhow::Result<(
Ok(())
}
-#[sqlx::test(fixtures(path = "../../../fixtures", scripts("user_notifications")))]
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("user_notifications"))
+)]
async fn test_bulk_delete_user_notification(pool: Pool<Postgres>) -> anyhow::Result<()> {
bulk_delete_user_notification(
&pool,
diff --git a/rust/cloud-storage/notification_db_client/src/user_notification/get/get_all.rs b/rust/cloud-storage/notification_db_client/src/user_notification/get/get_all.rs
index a0974ce805..2a5a5b4724 100644
--- a/rust/cloud-storage/notification_db_client/src/user_notification/get/get_all.rs
+++ b/rust/cloud-storage/notification_db_client/src/user_notification/get/get_all.rs
@@ -160,10 +160,14 @@ pub async fn get_all_user_notifications_by_event_item_ids(
mod tests {
use super::*;
use chrono::DateTime;
+ use macro_db_migrator::MACRO_DB_MIGRATIONS;
use models_pagination::{Base64Str, Cursor, CursorVal, PaginateOn, TypeEraseCursor};
use sqlx::{Pool, Postgres};
- #[sqlx::test(fixtures(path = "../../../fixtures", scripts("user_notifications")))]
+ #[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("user_notifications"))
+ )]
async fn test_get_user_notifications(pool: Pool<Postgres>) -> anyhow::Result<()> {
let paginated_result =
get_all_user_notifications(&pool, "macro|[email protected]", 1, Query::Sort(CreatedAt, ()))
@@ -197,7 +201,10 @@ mod tests {
Ok(())
}
- #[sqlx::test(fixtures(path = "../../../fixtures", scripts("user_notifications")))]
+ #[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("user_notifications"))
+ )]
async fn test_get_user_notifications_by_event_item_ids(
pool: Pool<Postgres>,
) -> anyhow::Result<()> {
diff --git a/rust/cloud-storage/notification_db_client/src/user_notification/get/get_by_id.rs b/rust/cloud-storage/notification_db_client/src/user_notification/get/get_by_id.rs
index 0b38a34576..a2d3802be4 100644
--- a/rust/cloud-storage/notification_db_client/src/user_notification/get/get_by_id.rs
+++ b/rust/cloud-storage/notification_db_client/src/user_notification/get/get_by_id.rs
@@ -74,9 +74,13 @@ pub async fn get_user_notification_by_id(
#[cfg(test)]
mod tests {
use super::*;
+ use macro_db_migrator::MACRO_DB_MIGRATIONS;
use sqlx::{Pool, Postgres};
- #[sqlx::test(fixtures(path = "../../../fixtures", scripts("user_notifications")))]
+ #[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("user_notifications"))
+ )]
async fn test_get_user_notification_by_id_found(pool: Pool<Postgres>) -> anyhow::Result<()> {
let notification_id = "0193b1ea-a542-7589-893b-2b4a509c1e76".parse::<Uuid>()?;
@@ -97,7 +101,10 @@ mod tests {
Ok(())
}
- #[sqlx::test(fixtures(path = "../../../fixtures", scripts("user_notifications")))]
+ #[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("user_notifications"))
+ )]
async fn test_get_user_notification_by_id_wrong_user(
pool: Pool<Postgres>,
) -> anyhow::Result<()> {
@@ -111,7 +118,10 @@ mod tests {
Ok(())
}
- #[sqlx::test(fixtures(path = "../../../fixtures", scripts("user_notifications")))]
+ #[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("user_notifications"))
+ )]
async fn test_get_user_notification_by_id_ignores_deleted(
pool: Pool<Postgres>,
) -> anyhow::Result<()> {
diff --git a/rust/cloud-storage/notification_db_client/src/user_notification/get/should_email.rs b/rust/cloud-storage/notification_db_client/src/user_notification/get/should_email.rs
index 1374feda27..1ea07e1975 100644
--- a/rust/cloud-storage/notification_db_client/src/user_notification/get/should_email.rs
+++ b/rust/cloud-storage/notification_db_client/src/user_notification/get/should_email.rs
@@ -52,9 +52,13 @@ pub async fn should_email_based_on_user_notification_bulk(
#[cfg(test)]
mod tests {
use super::*;
+ use macro_db_migrator::MACRO_DB_MIGRATIONS;
use sqlx::{Pool, Postgres};
- #[sqlx::test(fixtures(path = "../../../fixtures", scripts("should_email")))]
+ #[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("should_email"))
+ )]
async fn test_should_email_based_on_user_notification_bulk(
pool: Pool<Postgres>,
) -> anyhow::Result<()> {
diff --git a/rust/cloud-storage/notification_db_client/src/user_notification/get/unsent.rs b/rust/cloud-storage/notification_db_client/src/user_notification/get/unsent.rs
index d53bfc2dbf..3b32d116f2 100644
--- a/rust/cloud-storage/notification_db_client/src/user_notification/get/unsent.rs
+++ b/rust/cloud-storage/notification_db_client/src/user_notification/get/unsent.rs
@@ -65,6 +65,7 @@ pub async fn get_unsent_notifications_for_users(
#[cfg(test)]
mod tests {
use super::*;
+ use macro_db_migrator::MACRO_DB_MIGRATIONS;
use sqlx::{Pool, Postgres};
async fn populate_notifications(pool: &Pool<Postgres>) -> anyhow::Result<()> {
@@ -164,7 +165,7 @@ mod tests {
Ok(())
}
- #[sqlx::test]
+ #[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
async fn test_get_unsent_notifications_for_users(pool: Pool<Postgres>) -> anyhow::Result<()> {
populate_notifications(&pool).await?;
diff --git a/rust/cloud-storage/notification_db_client/src/user_notification/patch/done/test.rs b/rust/cloud-storage/notification_db_client/src/user_notification/patch/done/test.rs
index 62bd414555..98d5d25f96 100644
--- a/rust/cloud-storage/notification_db_client/src/user_notification/patch/done/test.rs
+++ b/rust/cloud-storage/notification_db_client/src/user_notification/patch/done/test.rs
@@ -1,7 +1,11 @@
use super::*;
+use macro_db_migrator::MACRO_DB_MIGRATIONS;
use sqlx::{Pool, Postgres};
-#[sqlx::test(fixtures(path = "../../../../fixtures", scripts("user_notifications")))]
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../../fixtures", scripts("user_notifications"))
+)]
async fn test_bulk_patch_undone(pool: Pool<Postgres>) -> anyhow::Result<()> {
let user_id = "macro|[email protected]";
let notification_ids = vec![
@@ -38,7 +42,10 @@ async fn test_bulk_patch_undone(pool: Pool<Postgres>) -> anyhow::Result<()> {
Ok(())
}
-#[sqlx::test(fixtures(path = "../../../../fixtures", scripts("user_notifications")))]
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../../fixtures", scripts("user_notifications"))
+)]
async fn test_patch_done(pool: Pool<Postgres>) -> anyhow::Result<()> {
let notification_id = "0193b1ea-a542-7589-893b-2b4a509c1e76";
let user_id = "macro|[email protected]";
@@ -61,7 +68,10 @@ async fn test_patch_done(pool: Pool<Postgres>) -> anyhow::Result<()> {
Ok(())
}
-#[sqlx::test(fixtures(path = "../../../../fixtures", scripts("user_notifications")))]
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../../fixtures", scripts("user_notifications"))
+)]
async fn test_bulk_patch_done(pool: Pool<Postgres>) -> anyhow::Result<()> {
let user_id = "macro|[email protected]";
let notification_ids = vec![
@@ -109,7 +119,10 @@ async fn test_bulk_patch_done(pool: Pool<Postgres>) -> anyhow::Result<()> {
Ok(())
}
-#[sqlx::test(fixtures(path = "../../../../fixtures", scripts("user_notifications")))]
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../../fixtures", scripts("user_notifications"))
+)]
async fn test_bulk_patch_done_by_event(pool: Pool<Postgres>) -> anyhow::Result<()> {
bulk_patch_done_by_event(&pool, "macro|[email protected]", "test").await?;
diff --git a/rust/cloud-storage/notification_db_client/src/user_notification/patch/seen/test.rs b/rust/cloud-storage/notification_db_client/src/user_notification/patch/seen/test.rs
index 96e5bed4d6..3c307d5f7c 100644
--- a/rust/cloud-storage/notification_db_client/src/user_notification/patch/seen/test.rs
+++ b/rust/cloud-storage/notification_db_client/src/user_notification/patch/seen/test.rs
@@ -1,7 +1,11 @@
use super::*;
+use macro_db_migrator::MACRO_DB_MIGRATIONS;
use sqlx::{Pool, Postgres};
-#[sqlx::test(fixtures(path = "../../../../fixtures", scripts("user_notifications")))]
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../../fixtures", scripts("user_notifications"))
+)]
async fn test_patch_seen(pool: Pool<Postgres>) -> anyhow::Result<()> {
let notification_id = "0193b1ea-a542-7589-893b-2b4a509c1e76";
let user_id = "macro|[email protected]";
@@ -23,7 +27,10 @@ async fn test_patch_seen(pool: Pool<Postgres>) -> anyhow::Result<()> {
Ok(())
}
-#[sqlx::test(fixtures(path = "../../../../fixtures", scripts("user_notifications")))]
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../../fixtures", scripts("user_notifications"))
+)]
async fn test_bulk_patch_seen(pool: Pool<Postgres>) -> anyhow::Result<()> {
let user_id = "macro|[email protected]";
let notification_ids = vec![
@@ -75,7 +82,10 @@ async fn test_bulk_patch_seen(pool: Pool<Postgres>) -> anyhow::Result<()> {
Ok(())
}
-#[sqlx::test(fixtures(path = "../../../../fixtures", scripts("user_notifications")))]
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../../fixtures", scripts("user_notifications"))
+)]
async fn test_bulk_patch_seen_by_event(pool: Pool<Postgres>) -> anyhow::Result<()> {
bulk_patch_seen_by_event(&pool, "macro|[email protected]", "test").await?;
diff --git a/rust/cloud-storage/notification_db_client/src/user_notification/patch/sent.rs b/rust/cloud-storage/notification_db_client/src/user_notification/patch/sent.rs
index 79ada165af..2194aefddd 100644
--- a/rust/cloud-storage/notification_db_client/src/user_notification/patch/sent.rs
+++ b/rust/cloud-storage/notification_db_client/src/user_notification/patch/sent.rs
@@ -49,9 +49,13 @@ pub async fn bulk_patch_sent_notification_event_item_ids(
#[cfg(test)]
mod tests {
use super::*;
+ use macro_db_migrator::MACRO_DB_MIGRATIONS;
use sqlx::{Pool, Postgres};
- #[sqlx::test(fixtures(path = "../../../fixtures", scripts("user_notifications")))]
+ #[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("user_notifications"))
+ )]
async fn test_bulk_patch_sent(pool: Pool<Postgres>) -> anyhow::Result<()> {
bulk_patch_sent(
&pool,