Fix: partner_profiles Alt-Schema-Migration — Tabelle aus verlorener v1102-Session existiert auf Staging/Prod (photos statt photos_json); Umbau mit Datenübernahme
This commit is contained in:
parent
ce8aa2b699
commit
21f54f478b
1 changed files with 32 additions and 0 deletions
|
|
@ -1633,6 +1633,38 @@ def _migrate(conn_factory):
|
||||||
# Partner-Profile (öffentlicher Showcase auf /#partner)
|
# Partner-Profile (öffentlicher Showcase auf /#partner)
|
||||||
# approved: 0=Entwurf/in Prüfung, 1=freigegeben, -1=abgelehnt
|
# approved: 0=Entwurf/in Prüfung, 1=freigegeben, -1=abgelehnt
|
||||||
try:
|
try:
|
||||||
|
# Alt-Schema aus der verlorenen v1102-Session (photos statt photos_json,
|
||||||
|
# id-Autoincrement-PK) kann auf Staging/Prod noch existieren → umbauen.
|
||||||
|
existing_cols = [r[1] for r in conn.execute(
|
||||||
|
"PRAGMA table_info(partner_profiles)"
|
||||||
|
).fetchall()]
|
||||||
|
if existing_cols and "photos_json" not in existing_cols:
|
||||||
|
conn.executescript("""
|
||||||
|
ALTER TABLE partner_profiles RENAME TO partner_profiles_old;
|
||||||
|
CREATE TABLE partner_profiles (
|
||||||
|
user_id INTEGER PRIMARY KEY REFERENCES users(id) ON DELETE CASCADE,
|
||||||
|
display_name TEXT,
|
||||||
|
tagline TEXT,
|
||||||
|
bio TEXT,
|
||||||
|
website TEXT,
|
||||||
|
instagram TEXT,
|
||||||
|
logo_url TEXT,
|
||||||
|
photos_json TEXT NOT NULL DEFAULT '[]',
|
||||||
|
approved INTEGER NOT NULL DEFAULT 0,
|
||||||
|
submitted_at TEXT,
|
||||||
|
updated_at TEXT,
|
||||||
|
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
||||||
|
);
|
||||||
|
INSERT INTO partner_profiles
|
||||||
|
(user_id, display_name, tagline, bio, website, instagram,
|
||||||
|
logo_url, photos_json, approved, submitted_at, updated_at, created_at)
|
||||||
|
SELECT user_id, display_name, tagline, bio, website, instagram,
|
||||||
|
logo_url, COALESCE(photos, '[]'), COALESCE(approved, 0),
|
||||||
|
submitted_at, NULL, datetime('now')
|
||||||
|
FROM partner_profiles_old;
|
||||||
|
DROP TABLE partner_profiles_old;
|
||||||
|
""")
|
||||||
|
logger.info("Migration: partner_profiles Alt-Schema → neues Schema umgebaut.")
|
||||||
conn.executescript("""
|
conn.executescript("""
|
||||||
CREATE TABLE IF NOT EXISTS partner_profiles (
|
CREATE TABLE IF NOT EXISTS partner_profiles (
|
||||||
user_id INTEGER PRIMARY KEY REFERENCES users(id) ON DELETE CASCADE,
|
user_id INTEGER PRIMARY KEY REFERENCES users(id) ON DELETE CASCADE,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue