mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-18 03:09:40 +02:00
27 lines
809 B
SQL
27 lines
809 B
SQL
-- Überprüfe die aktuelle Struktur der models-Tabelle
|
|
SELECT column_name, data_type
|
|
FROM information_schema.columns
|
|
WHERE table_name = 'models';
|
|
|
|
-- Füge die fehlenden Spalten hinzu, wenn sie nicht existieren
|
|
DO $$
|
|
BEGIN
|
|
-- Überprüfe, ob created_at existiert
|
|
IF NOT EXISTS (
|
|
SELECT 1
|
|
FROM information_schema.columns
|
|
WHERE table_name = 'models' AND column_name = 'created_at'
|
|
) THEN
|
|
ALTER TABLE models ADD COLUMN created_at TIMESTAMPTZ DEFAULT now();
|
|
END IF;
|
|
|
|
-- Überprüfe, ob updated_at existiert
|
|
IF NOT EXISTS (
|
|
SELECT 1
|
|
FROM information_schema.columns
|
|
WHERE table_name = 'models' AND column_name = 'updated_at'
|
|
) THEN
|
|
ALTER TABLE models ADD COLUMN updated_at TIMESTAMPTZ DEFAULT now();
|
|
END IF;
|
|
END
|
|
$$;
|