/*
  Warnings:

  - You are about to drop the column `country` on the `SupplierAddress` table. All the data in the column will be lost.
  - Added the required column `countryId` to the `SupplierAddress` table without a default value. This is not possible if the table is not empty.

*/
-- CreateTable
CREATE TABLE "Country" (
    "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    "name" TEXT NOT NULL,
    "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" DATETIME NOT NULL
);

-- RedefineTables
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_SupplierAddress" (
    "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    "supplierId" INTEGER NOT NULL,
    "title" TEXT NOT NULL,
    "address" TEXT NOT NULL,
    "postalCode" TEXT NOT NULL,
    "city" TEXT NOT NULL,
    "countryId" INTEGER NOT NULL,
    "published" BOOLEAN NOT NULL DEFAULT true,
    "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" DATETIME NOT NULL,
    CONSTRAINT "SupplierAddress_supplierId_fkey" FOREIGN KEY ("supplierId") REFERENCES "Supplier" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
    CONSTRAINT "SupplierAddress_countryId_fkey" FOREIGN KEY ("countryId") REFERENCES "Country" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
INSERT INTO "new_SupplierAddress" ("address", "city", "createdAt", "id", "postalCode", "published", "supplierId", "title", "updatedAt") SELECT "address", "city", "createdAt", "id", "postalCode", "published", "supplierId", "title", "updatedAt" FROM "SupplierAddress";
DROP TABLE "SupplierAddress";
ALTER TABLE "new_SupplierAddress" RENAME TO "SupplierAddress";
PRAGMA foreign_key_check;
PRAGMA foreign_keys=ON;
