rename to metadata

Signed-off-by: Frank Ye <franky@spotify.com>
This commit is contained in:
Frank Ye
2025-05-30 14:05:19 -04:00
parent 9152ba8f36
commit b345e53dd3
10 changed files with 41 additions and 42 deletions
@@ -16,18 +16,18 @@
exports.up = async function up(knex) {
await knex.schema.alterTable('notification', table => {
table.text('attributes').nullable();
table.text('metadata').nullable();
});
await knex.schema.alterTable('broadcast', table => {
table.text('attributes').nullable();
table.text('metadata').nullable();
});
};
exports.down = async function down(knex) {
await knex.schema.alterTable('notification', table => {
table.dropColumn('attributes');
table.dropColumn('metadata');
});
await knex.schema.alterTable('broadcast', table => {
table.dropColumn('attributes');
table.dropColumn('metadata');
});
};
+2 -2
View File
@@ -6,12 +6,12 @@
| Column | Type | Nullable | Max Length | Default |
| ------------- | -------------------------- | -------- | ---------- | ------------------- |
| `attributes` | `text` | true | - | - |
| `created` | `timestamp with time zone` | false | - | `CURRENT_TIMESTAMP` |
| `description` | `text` | true | - | - |
| `icon` | `character varying` | true | 255 | - |
| `id` | `uuid` | false | - | - |
| `link` | `text` | true | - | - |
| `metadata` | `text` | true | - | - |
| `origin` | `character varying` | false | 255 | - |
| `scope` | `character varying` | true | 255 | - |
| `severity` | `character varying` | false | 8 | - |
@@ -41,12 +41,12 @@
| Column | Type | Nullable | Max Length | Default |
| ------------- | -------------------------- | -------- | ---------- | ------------------- |
| `attributes` | `text` | true | - | - |
| `created` | `timestamp with time zone` | false | - | `CURRENT_TIMESTAMP` |
| `description` | `text` | true | - | - |
| `icon` | `character varying` | true | 255 | - |
| `id` | `uuid` | false | - | - |
| `link` | `text` | true | - | - |
| `metadata` | `text` | true | - | - |
| `origin` | `character varying` | false | 255 | - |
| `read` | `timestamp with time zone` | true | - | - |
| `saved` | `timestamp with time zone` | true | - | - |
@@ -69,8 +69,8 @@ const testNotification1: Notification = {
link: '/catalog',
severity: 'critical',
icon: 'docs',
attributes: {
attribute1: 'attributeValue',
metadata: {
attribute1: 'value1',
},
},
};
@@ -212,8 +212,8 @@ describe.each(databases.eachSupportedId())(
expect(notification?.payload?.link).toBe('/catalog');
expect(notification?.payload?.severity).toBe('critical');
expect(notification?.payload?.icon).toBe('docs');
expect(notification?.payload?.attributes).toEqual({
attribute1: 'attributeValue',
expect(notification?.payload?.metadata).toEqual({
attribute1: 'value1',
});
});
});
@@ -53,7 +53,7 @@ const NOTIFICATION_COLUMNS = [
'user',
'read',
'saved',
'attributes',
'metadata',
];
type NotificationRowType = {
@@ -165,7 +165,7 @@ export class DatabaseNotificationsStore implements NotificationsStore {
severity: row.severity,
scope: row.scope,
icon: row.icon,
attributes: row.attributes ? JSON.parse(row.attributes) : undefined,
metadata: row.metadata ? JSON.parse(row.metadata) : undefined,
},
}));
};
@@ -229,8 +229,8 @@ export class DatabaseNotificationsStore implements NotificationsStore {
icon: notification.payload?.icon,
saved: notification.saved,
read: notification.read,
attributes: notification.payload?.attributes
? JSON.stringify(notification.payload.attributes)
metadata: notification.payload?.metadata
? JSON.stringify(notification.payload.metadata)
: undefined,
};
};
@@ -247,8 +247,8 @@ export class DatabaseNotificationsStore implements NotificationsStore {
severity: normalizeSeverity(notification.payload?.severity),
icon: notification.payload.icon,
scope: notification.payload?.scope,
attributes: notification.payload?.attributes
? JSON.stringify(notification.payload.attributes)
metadata: notification.payload?.metadata
? JSON.stringify(notification.payload.metadata)
: undefined,
};
};
@@ -529,8 +529,8 @@ describe.each(databases.eachSupportedId())('createRouter (%s)', databaseId => {
title: 'Test broadcast notification',
created: new Date(),
severity: 'high',
attributes: {
attr1: 'attrValue',
metadata: {
attr1: 'value1',
},
});
await client('notification').insert({
@@ -540,8 +540,8 @@ describe.each(databases.eachSupportedId())('createRouter (%s)', databaseId => {
title: 'Test notification',
created: new Date(),
severity: 'normal',
attributes: {
attr1: 'attrValue',
metadata: {
attr1: 'value1',
},
});
@@ -561,8 +561,8 @@ describe.each(databases.eachSupportedId())('createRouter (%s)', databaseId => {
severity: 'normal',
title: 'Test notification',
topic: null,
attributes: {
attr1: 'attrValue',
metadata: {
attr1: 'value1',
},
},
read: null,
@@ -582,8 +582,8 @@ describe.each(databases.eachSupportedId())('createRouter (%s)', databaseId => {
severity: 'high',
title: 'Test broadcast notification',
topic: null,
attributes: {
attr1: 'attrValue',
metadata: {
attr1: 'value1',
},
},
read: null,