mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
Multiple image URLs (#4000)
* Backend changes - ported from scene impl * Front end changes * Refactor URL mutation code
This commit is contained in:
70
pkg/sqlite/migrations/50_image_urls.up.sql
Normal file
70
pkg/sqlite/migrations/50_image_urls.up.sql
Normal file
@@ -0,0 +1,70 @@
|
||||
PRAGMA foreign_keys=OFF;
|
||||
|
||||
CREATE TABLE `image_urls` (
|
||||
`image_id` integer NOT NULL,
|
||||
`position` integer NOT NULL,
|
||||
`url` varchar(255) NOT NULL,
|
||||
foreign key(`image_id`) references `images`(`id`) on delete CASCADE,
|
||||
PRIMARY KEY(`image_id`, `position`, `url`)
|
||||
);
|
||||
|
||||
CREATE INDEX `image_urls_url` on `image_urls` (`url`);
|
||||
|
||||
-- drop url
|
||||
CREATE TABLE "images_new" (
|
||||
`id` integer not null primary key autoincrement,
|
||||
`title` varchar(255),
|
||||
`rating` tinyint,
|
||||
`studio_id` integer,
|
||||
`o_counter` tinyint not null default 0,
|
||||
`organized` boolean not null default '0',
|
||||
`created_at` datetime not null,
|
||||
`updated_at` datetime not null,
|
||||
`date` date,
|
||||
foreign key(`studio_id`) references `studios`(`id`) on delete SET NULL
|
||||
);
|
||||
|
||||
INSERT INTO `images_new`
|
||||
(
|
||||
`id`,
|
||||
`title`,
|
||||
`rating`,
|
||||
`studio_id`,
|
||||
`o_counter`,
|
||||
`organized`,
|
||||
`created_at`,
|
||||
`updated_at`,
|
||||
`date`
|
||||
)
|
||||
SELECT
|
||||
`id`,
|
||||
`title`,
|
||||
`rating`,
|
||||
`studio_id`,
|
||||
`o_counter`,
|
||||
`organized`,
|
||||
`created_at`,
|
||||
`updated_at`,
|
||||
`date`
|
||||
FROM `images`;
|
||||
|
||||
INSERT INTO `image_urls`
|
||||
(
|
||||
`image_id`,
|
||||
`position`,
|
||||
`url`
|
||||
)
|
||||
SELECT
|
||||
`id`,
|
||||
'0',
|
||||
`url`
|
||||
FROM `images`
|
||||
WHERE `images`.`url` IS NOT NULL AND `images`.`url` != '';
|
||||
|
||||
DROP INDEX `index_images_on_studio_id`;
|
||||
DROP TABLE `images`;
|
||||
ALTER TABLE `images_new` rename to `images`;
|
||||
|
||||
CREATE INDEX `index_images_on_studio_id` on `images` (`studio_id`);
|
||||
|
||||
PRAGMA foreign_keys=ON;
|
||||
Reference in New Issue
Block a user