PRAGMA foreign_keys=OFF;--> statement-breakpoint
CREATE TABLE `__new_countries` (
	`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
	`slug` text NOT NULL,
	`iso_code` text NOT NULL,
	`sort_order` integer DEFAULT 0 NOT NULL,
	`created_at` integer NOT NULL,
	`updated_at` integer NOT NULL
);
--> statement-breakpoint
INSERT INTO `__new_countries`("id", "slug", "iso_code", "sort_order", "created_at", "updated_at") SELECT "id", "slug", "iso_code", "sort_order", "created_at", "updated_at" FROM `countries`;--> statement-breakpoint
DROP TABLE `countries`;--> statement-breakpoint
ALTER TABLE `__new_countries` RENAME TO `countries`;--> statement-breakpoint
CREATE UNIQUE INDEX `countries_slug_unique` ON `countries` (`slug`);--> statement-breakpoint
CREATE UNIQUE INDEX `countries_iso_code_unique` ON `countries` (`iso_code`);--> statement-breakpoint
CREATE TABLE `__new_country_locales` (
	`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
	`country_id` integer NOT NULL,
	`locale` text NOT NULL,
	`description` text,
	`body` text,
	FOREIGN KEY (`country_id`) REFERENCES `countries`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
INSERT INTO `__new_country_locales`("id", "country_id", "locale", "description", "body") SELECT "id", "country_id", "locale", "description", "body" FROM `country_locales`;--> statement-breakpoint
DROP TABLE `country_locales`;--> statement-breakpoint
ALTER TABLE `__new_country_locales` RENAME TO `country_locales`;--> statement-breakpoint
CREATE UNIQUE INDEX `country_locales_country_locale_unique` ON `country_locales` (`country_id`,`locale`);--> statement-breakpoint
PRAGMA foreign_keys=ON;
