fix(db): consolidate into single clean initial migration to prevent sqlite table alter collisions
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,76 +0,0 @@
|
|||||||
import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-sqlite'
|
|
||||||
|
|
||||||
export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
|
|
||||||
await db.run(sql`PRAGMA foreign_keys=OFF;`)
|
|
||||||
await db.run(sql`CREATE TABLE \`__new_navigation_locales\` (
|
|
||||||
\`tagline\` text DEFAULT 'Profesjonalne Mycie i Renowacja Nawierzchni Brukowych',
|
|
||||||
\`phone_label\` text DEFAULT 'Infolinia / Bezpłatna wycena:',
|
|
||||||
\`cta_button_label\` text DEFAULT 'KONTAKT',
|
|
||||||
\`cta_button_page_id\` integer,
|
|
||||||
\`cta_button_url\` text DEFAULT '#formularz-kontaktowy',
|
|
||||||
\`footer_tagline\` text DEFAULT 'Wyspecjalizowane usługi mycia gorącowodnego, usuwania mchu, odplamiania oleju, spoinowania i impregnacji hydrofobowej nawierzchni brukowych.',
|
|
||||||
\`nav_title\` text DEFAULT 'Nawigacja',
|
|
||||||
\`contact_title\` text DEFAULT 'Kontakt',
|
|
||||||
\`id\` integer PRIMARY KEY NOT NULL,
|
|
||||||
\`_locale\` text NOT NULL,
|
|
||||||
\`_parent_id\` integer NOT NULL,
|
|
||||||
FOREIGN KEY (\`cta_button_page_id\`) REFERENCES \`pages\`(\`id\`) ON UPDATE no action ON DELETE set null,
|
|
||||||
FOREIGN KEY (\`_parent_id\`) REFERENCES \`navigation\`(\`id\`) ON UPDATE no action ON DELETE cascade
|
|
||||||
);
|
|
||||||
`)
|
|
||||||
await db.run(sql`INSERT INTO \`__new_navigation_locales\`("tagline", "phone_label", "cta_button_label", "cta_button_page_id", "cta_button_url", "footer_tagline", "nav_title", "contact_title", "id", "_locale", "_parent_id") SELECT "tagline", "phone_label", "cta_button_label", "cta_button_page_id", "cta_button_url", "footer_tagline", "nav_title", "contact_title", "id", "_locale", "_parent_id" FROM \`navigation_locales\`;`)
|
|
||||||
await db.run(sql`DROP TABLE \`navigation_locales\`;`)
|
|
||||||
await db.run(sql`ALTER TABLE \`__new_navigation_locales\` RENAME TO \`navigation_locales\`;`)
|
|
||||||
await db.run(sql`PRAGMA foreign_keys=ON;`)
|
|
||||||
await db.run(sql`CREATE INDEX \`navigation_cta_button_cta_button_page_idx\` ON \`navigation_locales\` (\`cta_button_page_id\`);`)
|
|
||||||
await db.run(sql`CREATE UNIQUE INDEX \`navigation_locales_locale_parent_id_unique\` ON \`navigation_locales\` (\`_locale\`,\`_parent_id\`);`)
|
|
||||||
await db.run(sql`ALTER TABLE \`pages_blocks_hero_locales\` ADD \`cta_secondary_url\` text;`)
|
|
||||||
await db.run(sql`ALTER TABLE \`pages_blocks_pricing_table_packages\` ADD \`popular_badge_label\` text DEFAULT 'Polecany Pakiet';`)
|
|
||||||
await db.run(sql`ALTER TABLE \`pages_blocks_form_block_locales\` ADD \`direct_phone_label\` text DEFAULT 'Telefon bezpośredni';`)
|
|
||||||
await db.run(sql`ALTER TABLE \`pages_blocks_form_block_locales\` ADD \`email_contact_label\` text DEFAULT 'Kontakt e-mail';`)
|
|
||||||
await db.run(sql`ALTER TABLE \`pages_blocks_form_block_locales\` ADD \`working_hours_label\` text DEFAULT 'Godziny pracy';`)
|
|
||||||
await db.run(sql`ALTER TABLE \`pages_blocks_form_block_locales\` ADD \`name_label\` text DEFAULT 'Imię i Nazwisko *';`)
|
|
||||||
await db.run(sql`ALTER TABLE \`pages_blocks_form_block_locales\` ADD \`phone_input_label\` text DEFAULT 'Numer Telefonu *';`)
|
|
||||||
await db.run(sql`ALTER TABLE \`pages_blocks_form_block_locales\` ADD \`location_label\` text DEFAULT 'Miejscowość';`)
|
|
||||||
await db.run(sql`ALTER TABLE \`pages_blocks_form_block_locales\` ADD \`area_label\` text DEFAULT 'Szacowany Metraż (m²)';`)
|
|
||||||
await db.run(sql`ALTER TABLE \`pages_blocks_form_block_locales\` ADD \`message_label\` text DEFAULT 'Zakres prac / stan nawierzchni';`)
|
|
||||||
await db.run(sql`ALTER TABLE \`pages_blocks_form_block_locales\` ADD \`success_heading\` text DEFAULT 'Zgłoszenie zostało wysłane';`)
|
|
||||||
await db.run(sql`ALTER TABLE \`pages_blocks_form_block_locales\` ADD \`success_message\` text DEFAULT 'Nasz doradca techniczny skontaktuje się z Państwem telefonicznie w celu przygotowania dokładnej wyceny.';`)
|
|
||||||
await db.run(sql`ALTER TABLE \`pages_blocks_blog_list_locales\` ADD \`read_more_label\` text DEFAULT 'Czytaj poradnik';`)
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
|
|
||||||
await db.run(sql`PRAGMA foreign_keys=OFF;`)
|
|
||||||
await db.run(sql`CREATE TABLE \`__new_navigation_locales\` (
|
|
||||||
\`tagline\` text DEFAULT 'Czyszczenie Kostki Brukowej',
|
|
||||||
\`cta_button_label\` text DEFAULT 'Zadzwoń po wycenę',
|
|
||||||
\`cta_button_page_id\` integer,
|
|
||||||
\`cta_button_url\` text,
|
|
||||||
\`footer_tagline\` text DEFAULT 'Wyspecjalizowane usługi mycia gorącowodnego, usuwania mchu, odplamiania oleju, spoinowania i impregnacji hydrofobowej nawierzchni brukowych.',
|
|
||||||
\`id\` integer PRIMARY KEY NOT NULL,
|
|
||||||
\`_locale\` text NOT NULL,
|
|
||||||
\`_parent_id\` integer NOT NULL,
|
|
||||||
FOREIGN KEY (\`cta_button_page_id\`) REFERENCES \`pages\`(\`id\`) ON UPDATE no action ON DELETE set null,
|
|
||||||
FOREIGN KEY (\`_parent_id\`) REFERENCES \`navigation\`(\`id\`) ON UPDATE no action ON DELETE cascade
|
|
||||||
);
|
|
||||||
`)
|
|
||||||
await db.run(sql`INSERT INTO \`__new_navigation_locales\`("tagline", "cta_button_label", "cta_button_page_id", "cta_button_url", "footer_tagline", "id", "_locale", "_parent_id") SELECT "tagline", "cta_button_label", "cta_button_page_id", "cta_button_url", "footer_tagline", "id", "_locale", "_parent_id" FROM \`navigation_locales\`;`)
|
|
||||||
await db.run(sql`DROP TABLE \`navigation_locales\`;`)
|
|
||||||
await db.run(sql`ALTER TABLE \`__new_navigation_locales\` RENAME TO \`navigation_locales\`;`)
|
|
||||||
await db.run(sql`PRAGMA foreign_keys=ON;`)
|
|
||||||
await db.run(sql`CREATE INDEX \`navigation_cta_button_cta_button_page_idx\` ON \`navigation_locales\` (\`cta_button_page_id\`);`)
|
|
||||||
await db.run(sql`CREATE UNIQUE INDEX \`navigation_locales_locale_parent_id_unique\` ON \`navigation_locales\` (\`_locale\`,\`_parent_id\`);`)
|
|
||||||
await db.run(sql`ALTER TABLE \`pages_blocks_hero_locales\` DROP COLUMN \`cta_secondary_url\`;`)
|
|
||||||
await db.run(sql`ALTER TABLE \`pages_blocks_pricing_table_packages\` DROP COLUMN \`popular_badge_label\`;`)
|
|
||||||
await db.run(sql`ALTER TABLE \`pages_blocks_form_block_locales\` DROP COLUMN \`direct_phone_label\`;`)
|
|
||||||
await db.run(sql`ALTER TABLE \`pages_blocks_form_block_locales\` DROP COLUMN \`email_contact_label\`;`)
|
|
||||||
await db.run(sql`ALTER TABLE \`pages_blocks_form_block_locales\` DROP COLUMN \`working_hours_label\`;`)
|
|
||||||
await db.run(sql`ALTER TABLE \`pages_blocks_form_block_locales\` DROP COLUMN \`name_label\`;`)
|
|
||||||
await db.run(sql`ALTER TABLE \`pages_blocks_form_block_locales\` DROP COLUMN \`phone_input_label\`;`)
|
|
||||||
await db.run(sql`ALTER TABLE \`pages_blocks_form_block_locales\` DROP COLUMN \`location_label\`;`)
|
|
||||||
await db.run(sql`ALTER TABLE \`pages_blocks_form_block_locales\` DROP COLUMN \`area_label\`;`)
|
|
||||||
await db.run(sql`ALTER TABLE \`pages_blocks_form_block_locales\` DROP COLUMN \`message_label\`;`)
|
|
||||||
await db.run(sql`ALTER TABLE \`pages_blocks_form_block_locales\` DROP COLUMN \`success_heading\`;`)
|
|
||||||
await db.run(sql`ALTER TABLE \`pages_blocks_form_block_locales\` DROP COLUMN \`success_message\`;`)
|
|
||||||
await db.run(sql`ALTER TABLE \`pages_blocks_blog_list_locales\` DROP COLUMN \`read_more_label\`;`)
|
|
||||||
}
|
|
||||||
+1
-1
@@ -7886,6 +7886,6 @@
|
|||||||
"internal": {
|
"internal": {
|
||||||
"indexes": {}
|
"indexes": {}
|
||||||
},
|
},
|
||||||
"id": "a8912ac9-588c-48eb-a44c-99a28ecf3eb9",
|
"id": "f40c1d48-21f8-48b0-8a70-d4d7037cad8f",
|
||||||
"prevId": "00000000-0000-0000-0000-000000000000"
|
"prevId": "00000000-0000-0000-0000-000000000000"
|
||||||
}
|
}
|
||||||
@@ -124,6 +124,7 @@ export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
|
|||||||
\`cta_phone\` text,
|
\`cta_phone\` text,
|
||||||
\`cta_phone_label\` text,
|
\`cta_phone_label\` text,
|
||||||
\`cta_secondary_label\` text,
|
\`cta_secondary_label\` text,
|
||||||
|
\`cta_secondary_url\` text,
|
||||||
\`id\` integer PRIMARY KEY NOT NULL,
|
\`id\` integer PRIMARY KEY NOT NULL,
|
||||||
\`_locale\` text NOT NULL,
|
\`_locale\` text NOT NULL,
|
||||||
\`_parent_id\` text NOT NULL,
|
\`_parent_id\` text NOT NULL,
|
||||||
@@ -270,6 +271,7 @@ export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
|
|||||||
\`price\` text NOT NULL,
|
\`price\` text NOT NULL,
|
||||||
\`description\` text,
|
\`description\` text,
|
||||||
\`is_popular\` integer DEFAULT false,
|
\`is_popular\` integer DEFAULT false,
|
||||||
|
\`popular_badge_label\` text DEFAULT 'Polecany Pakiet',
|
||||||
\`cta_label\` text DEFAULT 'Zamów wycenę',
|
\`cta_label\` text DEFAULT 'Zamów wycenę',
|
||||||
FOREIGN KEY (\`_parent_id\`) REFERENCES \`pages_blocks_pricing_table\`(\`id\`) ON UPDATE no action ON DELETE cascade
|
FOREIGN KEY (\`_parent_id\`) REFERENCES \`pages_blocks_pricing_table\`(\`id\`) ON UPDATE no action ON DELETE cascade
|
||||||
);
|
);
|
||||||
@@ -431,10 +433,20 @@ export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
|
|||||||
\`heading\` text NOT NULL,
|
\`heading\` text NOT NULL,
|
||||||
\`subheading\` text,
|
\`subheading\` text,
|
||||||
\`phone\` text,
|
\`phone\` text,
|
||||||
|
\`direct_phone_label\` text DEFAULT 'Telefon bezpośredni',
|
||||||
\`email\` text,
|
\`email\` text,
|
||||||
|
\`email_contact_label\` text DEFAULT 'Kontakt e-mail',
|
||||||
\`working_hours\` text,
|
\`working_hours\` text,
|
||||||
|
\`working_hours_label\` text DEFAULT 'Godziny pracy',
|
||||||
|
\`name_label\` text DEFAULT 'Imię i Nazwisko *',
|
||||||
|
\`phone_input_label\` text DEFAULT 'Numer Telefonu *',
|
||||||
|
\`location_label\` text DEFAULT 'Miejscowość',
|
||||||
|
\`area_label\` text DEFAULT 'Szacowany Metraż (m²)',
|
||||||
|
\`message_label\` text DEFAULT 'Zakres prac / stan nawierzchni',
|
||||||
\`submit_button_text\` text DEFAULT 'Wyślij zapytanie o bezpłatną wycenę',
|
\`submit_button_text\` text DEFAULT 'Wyślij zapytanie o bezpłatną wycenę',
|
||||||
\`consent_text\` text DEFAULT 'Wyrażam zgodę na przetwarzanie moich danych osobowych w celu kontaktu i przygotowania oferty zgodnie z Polityką Prywatności.',
|
\`consent_text\` text DEFAULT 'Wyrażam zgodę na przetwarzanie moich danych osobowych w celu kontaktu i przygotowania oferty zgodnie z Polityką Prywatności.',
|
||||||
|
\`success_heading\` text DEFAULT 'Zgłoszenie zostało wysłane',
|
||||||
|
\`success_message\` text DEFAULT 'Nasz doradca techniczny skontaktuje się z Państwem telefonicznie w celu przygotowania dokładnej wyceny.',
|
||||||
\`id\` integer PRIMARY KEY NOT NULL,
|
\`id\` integer PRIMARY KEY NOT NULL,
|
||||||
\`_locale\` text NOT NULL,
|
\`_locale\` text NOT NULL,
|
||||||
\`_parent_id\` text NOT NULL,
|
\`_parent_id\` text NOT NULL,
|
||||||
@@ -498,6 +510,7 @@ export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
|
|||||||
\`badge\` text DEFAULT 'Baza Wiedzy & Porady',
|
\`badge\` text DEFAULT 'Baza Wiedzy & Porady',
|
||||||
\`heading\` text DEFAULT 'Poradnik czyszczenia i pielęgnacji kostki brukowej' NOT NULL,
|
\`heading\` text DEFAULT 'Poradnik czyszczenia i pielęgnacji kostki brukowej' NOT NULL,
|
||||||
\`subheading\` text DEFAULT 'Praktyczne wskazówki ekspertów: jak usuwać trudne plamy, kiedy impregnować nawierzchnię i dlaczego temperatura wody decyduje o skuteczności czyszczenia.',
|
\`subheading\` text DEFAULT 'Praktyczne wskazówki ekspertów: jak usuwać trudne plamy, kiedy impregnować nawierzchnię i dlaczego temperatura wody decyduje o skuteczności czyszczenia.',
|
||||||
|
\`read_more_label\` text DEFAULT 'Czytaj poradnik',
|
||||||
\`id\` integer PRIMARY KEY NOT NULL,
|
\`id\` integer PRIMARY KEY NOT NULL,
|
||||||
\`_locale\` text NOT NULL,
|
\`_locale\` text NOT NULL,
|
||||||
\`_parent_id\` text NOT NULL,
|
\`_parent_id\` text NOT NULL,
|
||||||
@@ -991,11 +1004,14 @@ export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
|
|||||||
);
|
);
|
||||||
`)
|
`)
|
||||||
await db.run(sql`CREATE TABLE \`navigation_locales\` (
|
await db.run(sql`CREATE TABLE \`navigation_locales\` (
|
||||||
\`tagline\` text DEFAULT 'Czyszczenie Kostki Brukowej',
|
\`tagline\` text DEFAULT 'Profesjonalne Mycie i Renowacja Nawierzchni Brukowych',
|
||||||
\`cta_button_label\` text DEFAULT 'Zadzwoń po wycenę',
|
\`phone_label\` text DEFAULT 'Infolinia / Bezpłatna wycena:',
|
||||||
|
\`cta_button_label\` text DEFAULT 'KONTAKT',
|
||||||
\`cta_button_page_id\` integer,
|
\`cta_button_page_id\` integer,
|
||||||
\`cta_button_url\` text,
|
\`cta_button_url\` text DEFAULT '#formularz-kontaktowy',
|
||||||
\`footer_tagline\` text DEFAULT 'Wyspecjalizowane usługi mycia gorącowodnego, usuwania mchu, odplamiania oleju, spoinowania i impregnacji hydrofobowej nawierzchni brukowych.',
|
\`footer_tagline\` text DEFAULT 'Wyspecjalizowane usługi mycia gorącowodnego, usuwania mchu, odplamiania oleju, spoinowania i impregnacji hydrofobowej nawierzchni brukowych.',
|
||||||
|
\`nav_title\` text DEFAULT 'Nawigacja',
|
||||||
|
\`contact_title\` text DEFAULT 'Kontakt',
|
||||||
\`id\` integer PRIMARY KEY NOT NULL,
|
\`id\` integer PRIMARY KEY NOT NULL,
|
||||||
\`_locale\` text NOT NULL,
|
\`_locale\` text NOT NULL,
|
||||||
\`_parent_id\` integer NOT NULL,
|
\`_parent_id\` integer NOT NULL,
|
||||||
+4
-10
@@ -1,15 +1,9 @@
|
|||||||
import * as migration_20260826_005622_init from './20260826_005622_init';
|
import * as migration_20260826_011445_init from './20260826_011445_init';
|
||||||
import * as migration_20260826_011138_update_schema from './20260826_011138_update_schema';
|
|
||||||
|
|
||||||
export const migrations = [
|
export const migrations = [
|
||||||
{
|
{
|
||||||
up: migration_20260826_005622_init.up,
|
up: migration_20260826_011445_init.up,
|
||||||
down: migration_20260826_005622_init.down,
|
down: migration_20260826_011445_init.down,
|
||||||
name: '20260826_005622_init',
|
name: '20260826_011445_init'
|
||||||
},
|
|
||||||
{
|
|
||||||
up: migration_20260826_011138_update_schema.up,
|
|
||||||
down: migration_20260826_011138_update_schema.down,
|
|
||||||
name: '20260826_011138_update_schema'
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user