Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report] Database Migration Failure #5361

Closed
lynsix opened this issue Oct 10, 2024 · 2 comments · Fixed by #5363
Closed

[Bug Report] Database Migration Failure #5361

lynsix opened this issue Oct 10, 2024 · 2 comments · Fixed by #5363
Labels
bug report Bug reports that are not yet verified

Comments

@lynsix
Copy link

lynsix commented Oct 10, 2024

Whenever I attempt to upgrade from 0.26.2 to 0.27+ database migration fails.
I'm able to roll back to 2.6.2 and Stash continues to function normally.
Have cleaned, and optimized database and attempted to rerun.

To Reproduce
Update docker container to 0.27 or 0.27.1

Expected behavior
Would expect the migration to finish without errors as it always has in the past.

Screenshots
Not really a screenshot but just the error that is dumped while migrating the database.
What seems like the relevant part of the error to me: "error performing migration: error running migration for schema 62: no such index: performers_name_disambiguation_unique in line 0: PRAGMA foreign_keys=OFF;"

Full Error Text

`An error occurred migrating the database to the latest schema version. The backup database file was automatically renamed to restore the database. error performing migration: error running migration for schema 62: no such index: performers_name_disambiguation_unique in line 0: PRAGMA foreign_keys=OFF;

CREATE TABLE performer_urls (
performer_id integer NOT NULL,
position integer NOT NULL,
url varchar(255) NOT NULL,
foreign key(performer_id) references performers(id) on delete CASCADE,
PRIMARY KEY(performer_id, position, url)
);

CREATE INDEX performers_urls_url on performer_urls (url);

-- drop url, twitter and instagram
-- make name not null
CREATE TABLE performers_new (
id integer not null primary key autoincrement,
name varchar(255) not null,
disambiguation varchar(255),
gender varchar(20),
birthdate date,
ethnicity varchar(255),
country varchar(255),
eye_color varchar(255),
height int,
measurements varchar(255),
fake_tits varchar(255),
career_length varchar(255),
tattoos varchar(255),
piercings varchar(255),
favorite boolean not null default '0',
created_at datetime not null,
updated_at datetime not null,
details text,
death_date date,
hair_color varchar(255),
weight integer,
rating tinyint,
ignore_auto_tag boolean not null default '0',
image_blob varchar(255) REFERENCES blobs(checksum),
penis_length float,
circumcised varchar[10]
);

INSERT INTO performers_new
(
id,
name,
disambiguation,
gender,
birthdate,
ethnicity,
country,
eye_color,
height,
measurements,
fake_tits,
career_length,
tattoos,
piercings,
favorite,
created_at,
updated_at,
details,
death_date,
hair_color,
weight,
rating,
ignore_auto_tag,
image_blob,
penis_length,
circumcised
)
SELECT
id,
name,
disambiguation,
gender,
birthdate,
ethnicity,
country,
eye_color,
height,
measurements,
fake_tits,
career_length,
tattoos,
piercings,
favorite,
created_at,
updated_at,
details,
death_date,
hair_color,
weight,
rating,
ignore_auto_tag,
image_blob,
penis_length,
circumcised
FROM performers;

INSERT INTO performer_urls
(
performer_id,
position,
url
)
SELECT
id,
'0',
url
FROM performers
WHERE performers.url IS NOT NULL AND performers.url != '';

INSERT INTO performer_urls
(
performer_id,
position,
url
)
SELECT
id,
(SELECT count(*) FROM performer_urls WHERE performer_id = performers.id)+1,
CASE
WHEN twitter LIKE 'http%://%' THEN twitter
ELSE 'https://www.twitter.com/' || twitter
END
FROM performers
WHERE performers.twitter IS NOT NULL AND performers.twitter != '';

INSERT INTO performer_urls
(
performer_id,
position,
url
)
SELECT
id,
(SELECT count(*) FROM performer_urls WHERE performer_id = performers.id)+1,
CASE
WHEN instagram LIKE 'http%://%' THEN instagram
ELSE 'https://www.instagram.com/' || instagram
END
FROM performers
WHERE performers.instagram IS NOT NULL AND performers.instagram != '';

DROP INDEX performers_name_disambiguation_unique;
DROP INDEX performers_name_unique;
DROP TABLE performers;
ALTER TABLE performers_new rename to performers;

CREATE UNIQUE INDEX performers_name_disambiguation_unique on performers (name, disambiguation) WHERE disambiguation IS NOT NULL;
CREATE UNIQUE INDEX performers_name_unique on performers (name) WHERE disambiguation IS NULL;

PRAGMA foreign_keys=ON;`

**Stash Version: (from Settings -> About):** 26.2 database schema version 58. Error appears to happen when migrating to schema 62.

Additional context
I did attempt to get help on the Discord first but didn't get any responses.

@lynsix lynsix added the bug report Bug reports that are not yet verified label Oct 10, 2024
@github-project-automation github-project-automation bot moved this to To triage in Bug fixing Oct 10, 2024
@arshad-k7
Copy link
Contributor

Please check this #5363

@DogmaDragon DogmaDragon linked a pull request Oct 11, 2024 that will close this issue
@github-project-automation github-project-automation bot moved this from To triage to Done in Bug fixing Oct 15, 2024
@lynsix
Copy link
Author

lynsix commented Oct 25, 2024

This didn't seem to fix the issue. I tried both Arshad-k7's fork as well as the updated 0.27.2 release.
I assume it's got something to do with performers with the same name and a disambiguation line in them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Bug reports that are not yet verified
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants