mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00
fix: update migration script (#4065)
* fix: update migration script fix: remove insert for new entities * fix: correct migration name * fix: correct name inside migration
This commit is contained in:
@@ -5,20 +5,10 @@ export class UpdateWebPush1740717744278 implements MigrationInterface {
|
|||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
await queryRunner.query(
|
await queryRunner.query(
|
||||||
`CREATE TABLE "temporary_user_push_subscription" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "endpoint" varchar NOT NULL, "p256dh" varchar NOT NULL, "auth" varchar NOT NULL, "userId" integer, "userAgent" varchar, "createdAt" datetime DEFAULT (datetime('now')), CONSTRAINT "UQ_f90ab5a4ed54905a4bb51a7148b" UNIQUE ("auth"), CONSTRAINT "FK_03f7958328e311761b0de675fbe" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`
|
`CREATE TABLE "temporary_user_push_subscription" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "endpoint" varchar NOT NULL, "p256dh" varchar NOT NULL, "auth" varchar NOT NULL, "userId" integer, "userAgent" varchar DEFAULT NULL, "createdAt" datetime DEFAULT (datetime('now')), CONSTRAINT "UQ_f90ab5a4ed54905a4bb51a7148b" UNIQUE ("auth"), CONSTRAINT "FK_03f7958328e311761b0de675fbe" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`
|
||||||
);
|
);
|
||||||
await queryRunner.query(
|
await queryRunner.query(
|
||||||
`INSERT INTO "temporary_user_push_subscription"("id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt") SELECT "id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt" FROM "user_push_subscription"`
|
`INSERT INTO "temporary_user_push_subscription"("id", "endpoint", "p256dh", "auth", "userId") SELECT "id", "endpoint", "p256dh", "auth", "userId" FROM "user_push_subscription"`
|
||||||
);
|
|
||||||
await queryRunner.query(`DROP TABLE "user_push_subscription"`);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "temporary_user_push_subscription" RENAME TO "user_push_subscription"`
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TABLE "temporary_user_push_subscription" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "endpoint" varchar NOT NULL, "p256dh" varchar NOT NULL, "auth" varchar NOT NULL, "userId" integer, "userAgent" varchar, "createdAt" datetime DEFAULT (datetime('now')), CONSTRAINT "UQ_f90ab5a4ed54905a4bb51a7148b" UNIQUE ("auth"), CONSTRAINT "FK_03f7958328e311761b0de675fbe" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`INSERT INTO "temporary_user_push_subscription"("id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt") SELECT "id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt" FROM "user_push_subscription"`
|
|
||||||
);
|
);
|
||||||
await queryRunner.query(`DROP TABLE "user_push_subscription"`);
|
await queryRunner.query(`DROP TABLE "user_push_subscription"`);
|
||||||
await queryRunner.query(
|
await queryRunner.query(
|
||||||
@@ -34,17 +24,7 @@ export class UpdateWebPush1740717744278 implements MigrationInterface {
|
|||||||
`CREATE TABLE "user_push_subscription" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "endpoint" varchar NOT NULL, "p256dh" varchar NOT NULL, "auth" varchar NOT NULL, "userId" integer, "userAgent" varchar, "createdAt" datetime DEFAULT (datetime('now')), CONSTRAINT "UQ_f90ab5a4ed54905a4bb51a7148b" UNIQUE ("auth"), CONSTRAINT "FK_03f7958328e311761b0de675fbe" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`
|
`CREATE TABLE "user_push_subscription" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "endpoint" varchar NOT NULL, "p256dh" varchar NOT NULL, "auth" varchar NOT NULL, "userId" integer, "userAgent" varchar, "createdAt" datetime DEFAULT (datetime('now')), CONSTRAINT "UQ_f90ab5a4ed54905a4bb51a7148b" UNIQUE ("auth"), CONSTRAINT "FK_03f7958328e311761b0de675fbe" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`
|
||||||
);
|
);
|
||||||
await queryRunner.query(
|
await queryRunner.query(
|
||||||
`INSERT INTO "user_push_subscription"("id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt") SELECT "id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt" FROM "temporary_user_push_subscription"`
|
`INSERT INTO "user_push_subscription"("id", "endpoint", "p256dh", "auth", "userId") SELECT "id", "endpoint", "p256dh", "auth", "userId" FROM "temporary_user_push_subscription"`
|
||||||
);
|
|
||||||
await queryRunner.query(`DROP TABLE "temporary_user_push_subscription"`);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "user_push_subscription" RENAME TO "temporary_user_push_subscription"`
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TABLE "user_push_subscription" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "endpoint" varchar NOT NULL, "p256dh" varchar NOT NULL, "auth" varchar NOT NULL, "userId" integer, "userAgent" varchar, "createdAt" datetime DEFAULT (datetime('now')), CONSTRAINT "UQ_f90ab5a4ed54905a4bb51a7148b" UNIQUE ("auth"), CONSTRAINT "FK_03f7958328e311761b0de675fbe" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`INSERT INTO "user_push_subscription"("id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt") SELECT "id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt" FROM "temporary_user_push_subscription"`
|
|
||||||
);
|
);
|
||||||
await queryRunner.query(`DROP TABLE "temporary_user_push_subscription"`);
|
await queryRunner.query(`DROP TABLE "temporary_user_push_subscription"`);
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,7 @@ const messages = defineMessages({
|
|||||||
browser: 'Browser',
|
browser: 'Browser',
|
||||||
engine: 'Engine',
|
engine: 'Engine',
|
||||||
deletesubscription: 'Delete Subscription',
|
deletesubscription: 'Delete Subscription',
|
||||||
|
unknown: 'Unknown',
|
||||||
});
|
});
|
||||||
|
|
||||||
const DeviceItem = ({ disablePushNotifications, device }: DeviceItemProps) => {
|
const DeviceItem = ({ disablePushNotifications, device }: DeviceItemProps) => {
|
||||||
@@ -48,12 +49,12 @@ const DeviceItem = ({ disablePushNotifications, device }: DeviceItemProps) => {
|
|||||||
month: 'long',
|
month: 'long',
|
||||||
day: 'numeric',
|
day: 'numeric',
|
||||||
})
|
})
|
||||||
: 'Unknown'}
|
: 'N/A'}
|
||||||
</div>
|
</div>
|
||||||
<div className="mr-2 min-w-0 truncate text-lg font-bold text-white hover:underline xl:text-xl">
|
<div className="mr-2 min-w-0 truncate text-lg font-bold text-white hover:underline xl:text-xl">
|
||||||
{device.userAgent
|
{device.userAgent
|
||||||
? UAParser(device.userAgent).device.model
|
? UAParser(device.userAgent).device.model
|
||||||
: 'Unknown'}
|
: intl.formatMessage(messages.unknown)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -63,9 +64,7 @@ const DeviceItem = ({ disablePushNotifications, device }: DeviceItemProps) => {
|
|||||||
{intl.formatMessage(messages.operatingsystem)}
|
{intl.formatMessage(messages.operatingsystem)}
|
||||||
</span>
|
</span>
|
||||||
<span className="flex truncate text-sm text-gray-300">
|
<span className="flex truncate text-sm text-gray-300">
|
||||||
{device.userAgent
|
{device.userAgent ? UAParser(device.userAgent).os.name : 'N/A'}
|
||||||
? UAParser(device.userAgent).os.name
|
|
||||||
: 'Unknown'}
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="card-field">
|
<div className="card-field">
|
||||||
@@ -75,7 +74,7 @@ const DeviceItem = ({ disablePushNotifications, device }: DeviceItemProps) => {
|
|||||||
<span className="flex truncate text-sm text-gray-300">
|
<span className="flex truncate text-sm text-gray-300">
|
||||||
{device.userAgent
|
{device.userAgent
|
||||||
? UAParser(device.userAgent).browser.name
|
? UAParser(device.userAgent).browser.name
|
||||||
: 'Unknown'}
|
: 'N/A'}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="card-field">
|
<div className="card-field">
|
||||||
@@ -85,7 +84,7 @@ const DeviceItem = ({ disablePushNotifications, device }: DeviceItemProps) => {
|
|||||||
<span className="flex truncate text-sm text-gray-300">
|
<span className="flex truncate text-sm text-gray-300">
|
||||||
{device.userAgent
|
{device.userAgent
|
||||||
? UAParser(device.userAgent).engine.name
|
? UAParser(device.userAgent).engine.name
|
||||||
: 'Unknown'}
|
: 'N/A'}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -312,15 +312,21 @@ const UserWebPushSettings = () => {
|
|||||||
</h3>
|
</h3>
|
||||||
<div className="section">
|
<div className="section">
|
||||||
{dataDevices?.length ? (
|
{dataDevices?.length ? (
|
||||||
dataDevices?.map((device, index) => (
|
dataDevices
|
||||||
<div className="py-2" key={`device-list-${index}`}>
|
?.sort((a, b) => {
|
||||||
<DeviceItem
|
const dateA = a.createdAt ? new Date(a.createdAt).getTime() : 0;
|
||||||
key={index}
|
const dateB = b.createdAt ? new Date(b.createdAt).getTime() : 0;
|
||||||
disablePushNotifications={disablePushNotifications}
|
return dateB - dateA;
|
||||||
device={device}
|
})
|
||||||
/>
|
.map((device, index) => (
|
||||||
</div>
|
<div className="py-2" key={`device-list-${index}`}>
|
||||||
))
|
<DeviceItem
|
||||||
|
key={index}
|
||||||
|
disablePushNotifications={disablePushNotifications}
|
||||||
|
device={device}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
))
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<Alert
|
<Alert
|
||||||
|
@@ -1121,6 +1121,7 @@
|
|||||||
"components.UserProfile.UserSettings.UserNotificationSettings.UserNotificationsWebPush.subscriptiondeleted": "Subscription deleted.",
|
"components.UserProfile.UserSettings.UserNotificationSettings.UserNotificationsWebPush.subscriptiondeleted": "Subscription deleted.",
|
||||||
"components.UserProfile.UserSettings.UserNotificationSettings.UserNotificationsWebPush.subscriptiondeleteerror": "Something went wrong while deleting the user subscription.",
|
"components.UserProfile.UserSettings.UserNotificationSettings.UserNotificationsWebPush.subscriptiondeleteerror": "Something went wrong while deleting the user subscription.",
|
||||||
"components.UserProfile.UserSettings.UserNotificationSettings.UserNotificationsWebPush.type": "type",
|
"components.UserProfile.UserSettings.UserNotificationSettings.UserNotificationsWebPush.type": "type",
|
||||||
|
"components.UserProfile.UserSettings.UserNotificationSettings.UserNotificationsWebPush.unknown": "Unknown",
|
||||||
"components.UserProfile.UserSettings.UserNotificationSettings.UserNotificationsWebPush.webpushhasbeendisabled": "Web push has been disabled.",
|
"components.UserProfile.UserSettings.UserNotificationSettings.UserNotificationsWebPush.webpushhasbeendisabled": "Web push has been disabled.",
|
||||||
"components.UserProfile.UserSettings.UserNotificationSettings.UserNotificationsWebPush.webpushhasbeenenabled": "Web push has been enabled.",
|
"components.UserProfile.UserSettings.UserNotificationSettings.UserNotificationsWebPush.webpushhasbeenenabled": "Web push has been enabled.",
|
||||||
"components.UserProfile.UserSettings.UserNotificationSettings.UserNotificationsWebPush.webpushsettingsfailed": "Web push notification settings failed to save.",
|
"components.UserProfile.UserSettings.UserNotificationSettings.UserNotificationsWebPush.webpushsettingsfailed": "Web push notification settings failed to save.",
|
||||||
|
Reference in New Issue
Block a user