Compare commits
2
Commits
14ad2fd0f8
...
00ba8b9dd3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
00ba8b9dd3 | ||
|
|
d7e0171b2f |
@@ -0,0 +1,24 @@
|
||||
exports.up = async function(knex) {
|
||||
const orphanedAvatars = await knex('actors_avatars')
|
||||
.whereNull('profile_id');
|
||||
|
||||
if (orphanedAvatars.length > 0) {
|
||||
console.log(`Deleting ${orphanedAvatars.length} actors_avatars rows with no profile_id`);
|
||||
}
|
||||
|
||||
await knex('actors_avatars')
|
||||
.whereNull('profile_id')
|
||||
.delete();
|
||||
|
||||
await knex.raw(`
|
||||
DROP INDEX IF EXISTS unique_main_avatars;
|
||||
ALTER TABLE actors_avatars ALTER COLUMN profile_id SET NOT NULL;
|
||||
`);
|
||||
};
|
||||
|
||||
exports.down = async function(knex) {
|
||||
await knex.raw(`
|
||||
ALTER TABLE actors_avatars ALTER COLUMN profile_id DROP NOT NULL;
|
||||
CREATE UNIQUE INDEX unique_main_avatars ON actors_avatars (actor_id) WHERE (profile_id IS NULL);
|
||||
`);
|
||||
};
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "traxxx",
|
||||
"version": "1.255.2",
|
||||
"version": "1.255.3",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "traxxx",
|
||||
"version": "1.255.2",
|
||||
"version": "1.255.3",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "^3.458.0",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "traxxx",
|
||||
"version": "1.255.2",
|
||||
"version": "1.255.3",
|
||||
"description": "All the latest porn releases in one place",
|
||||
"main": "src/app.js",
|
||||
"scripts": {
|
||||
|
||||
+9
-2
@@ -611,8 +611,15 @@ async function upsertProfiles(profiles) {
|
||||
media_id: profile.avatarMediaId,
|
||||
}));
|
||||
|
||||
if (avatars.length > 0) {
|
||||
await batchInsert('actors_avatars', avatars, { conflict: false });
|
||||
const resolvedAvatars = avatars.filter((avatar) => !!avatar.profile_id);
|
||||
const unresolvedAvatars = avatars.filter((avatar) => !avatar.profile_id);
|
||||
|
||||
unresolvedAvatars.forEach((avatar) => {
|
||||
logger.warn(`Skipping avatar for actor ${avatar.actor_id} (${avatar.media_id}), no profile could be resolved`);
|
||||
});
|
||||
|
||||
if (resolvedAvatars.length > 0) {
|
||||
await batchInsert('actors_avatars', resolvedAvatars, { conflict: false });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user