drizzle-orm: [BUG]: how to recover from snapshot.json data is malformed

What version of drizzle-orm are you using?

latest

What version of drizzle-kit are you using?

latest

Describe the Bug

When trying drizzle-kit generate:sqlite --config drizzle.config.ts I get

drizzle-kit: v0.20.4
drizzle-orm: v0.29.0

Reading config file '/Users/nikos/WebstormProjects/coffeeconnect/drizzle.config.ts'
drizzle/meta/0000_snapshot.json data is malformed

the json doesnt have any syntax errors

Expected behavior

migration created

Environment & setup

MAC OS 14.0 (23A339) node v20.9.0

the JSON:

{
  "version": "5",
  "dialect": "sqlite",
  "id": "2420c080-21b9-47c6-9e05-77c947766f87",
  "prevId": "00000000-0000-0000-0000-000000000000",
  "tables": {
    "audit_log": {
      "name": "audit_log",
      "columns": {
        "id": {
          "name": "id",
          "type": "integer",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": true
        },
        "action": {
          "name": "action",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "table": {
          "name": "table",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "record_id": {
          "name": "record_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "data": {
          "name": "data",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "user_id": {
          "name": "user_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {},
      "foreignKeys": {
        "audit_log_user_id_user_id_fk": {
          "name": "audit_log_user_id_user_id_fk",
          "tableFrom": "audit_log",
          "tableTo": "user",
          "columnsFrom": [
            "user_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {}
    },
    "booking": {
      "name": "booking",
      "columns": {
        "id": {
          "name": "id",
          "type": "integer",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": true
        },
        "user_id": {
          "name": "user_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "coupon_id": {
          "name": "coupon_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "discount_percentage": {
          "name": "discount_percentage",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "discount_value": {
          "name": "discount_value",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "coupon_snapshot": {
          "name": "coupon_snapshot",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {},
      "foreignKeys": {
        "booking_user_id_user_id_fk": {
          "name": "booking_user_id_user_id_fk",
          "tableFrom": "booking",
          "tableTo": "user",
          "columnsFrom": [
            "user_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "booking_coupon_id_coupon_id_fk": {
          "name": "booking_coupon_id_coupon_id_fk",
          "tableFrom": "booking",
          "tableTo": "coupon",
          "columnsFrom": [
            "coupon_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {}
    },
    "booking_option": {
      "name": "booking_option",
      "columns": {
        "booking_id": {
          "name": "booking_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "option_id": {
          "name": "option_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "quantity": {
          "name": "quantity",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 1
        },
        "unit_price": {
          "name": "unit_price",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "option_snapshot": {
          "name": "option_snapshot",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        }
      },
      "indexes": {},
      "foreignKeys": {
        "booking_option_booking_id_booking_id_fk": {
          "name": "booking_option_booking_id_booking_id_fk",
          "tableFrom": "booking_option",
          "tableTo": "booking",
          "columnsFrom": [
            "booking_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "booking_option_option_id_option_id_fk": {
          "name": "booking_option_option_id_option_id_fk",
          "tableFrom": "booking_option",
          "tableTo": "option",
          "columnsFrom": [
            "option_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {
        "booking_option_booking_id_option_id_pk": {
          "columns": [
            "booking_id",
            "option_id"
          ]
        }
      },
      "uniqueConstraints": {}
    },
    "booking_slot": {
      "name": "booking_slot",
      "columns": {
        "booking_id": {
          "name": "booking_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "slot_id": {
          "name": "slot_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "start_time": {
          "name": "start_time",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "length": {
          "name": "length",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "block_price": {
          "name": "block_price",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "block_quantity": {
          "name": "block_quantity",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "slot_snapshot": {
          "name": "slot_snapshot",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        }
      },
      "indexes": {},
      "foreignKeys": {
        "booking_slot_booking_id_booking_id_fk": {
          "name": "booking_slot_booking_id_booking_id_fk",
          "tableFrom": "booking_slot",
          "tableTo": "booking",
          "columnsFrom": [
            "booking_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "booking_slot_slot_id_slot_id_fk": {
          "name": "booking_slot_slot_id_slot_id_fk",
          "tableFrom": "booking_slot",
          "tableTo": "slot",
          "columnsFrom": [
            "slot_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {
        "booking_slot_booking_id_slot_id_pk": {
          "columns": [
            "booking_id",
            "slot_id"
          ]
        }
      },
      "uniqueConstraints": {}
    },
    "coupon": {
      "name": "coupon",
      "columns": {
        "id": {
          "name": "id",
          "type": "integer",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": true
        },
        "code": {
          "name": "code",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "discount_percentage": {
          "name": "discount_percentage",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "discount_value": {
          "name": "discount_value",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "quantity": {
          "name": "quantity",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "valid_from": {
          "name": "valid_from",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "valid_to": {
          "name": "valid_to",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "expires_at": {
          "name": "expires_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "organisation_id": {
          "name": "organisation_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "space_id": {
          "name": "space_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "slot_id": {
          "name": "slot_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "deleted_at": {
          "name": "deleted_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        }
      },
      "indexes": {
        "coupon_code_organisation_id_deleted_at_unique": {
          "name": "coupon_code_organisation_id_deleted_at_unique",
          "columns": [
            "code",
            "organisation_id",
            "deleted_at"
          ],
          "isUnique": true
        }
      },
      "foreignKeys": {
        "coupon_organisation_id_organisation_id_fk": {
          "name": "coupon_organisation_id_organisation_id_fk",
          "tableFrom": "coupon",
          "tableTo": "organisation",
          "columnsFrom": [
            "organisation_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "coupon_space_id_space_id_fk": {
          "name": "coupon_space_id_space_id_fk",
          "tableFrom": "coupon",
          "tableTo": "space",
          "columnsFrom": [
            "space_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "coupon_slot_id_slot_id_fk": {
          "name": "coupon_slot_id_slot_id_fk",
          "tableFrom": "coupon",
          "tableTo": "slot",
          "columnsFrom": [
            "slot_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {}
    },
    "option": {
      "name": "option",
      "columns": {
        "id": {
          "name": "id",
          "type": "integer",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": true
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "unit_price": {
          "name": "unit_price",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "max_units": {
          "name": "max_units",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 1
        },
        "organisation_id": {
          "name": "organisation_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "space_id": {
          "name": "space_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "slote_id": {
          "name": "slote_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "deleted_at": {
          "name": "deleted_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        }
      },
      "indexes": {},
      "foreignKeys": {
        "option_organisation_id_organisation_id_fk": {
          "name": "option_organisation_id_organisation_id_fk",
          "tableFrom": "option",
          "tableTo": "organisation",
          "columnsFrom": [
            "organisation_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "option_space_id_space_id_fk": {
          "name": "option_space_id_space_id_fk",
          "tableFrom": "option",
          "tableTo": "space",
          "columnsFrom": [
            "space_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "option_slote_id_slot_id_fk": {
          "name": "option_slote_id_slot_id_fk",
          "tableFrom": "option",
          "tableTo": "slot",
          "columnsFrom": [
            "slote_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {}
    },
    "organisation": {
      "name": "organisation",
      "columns": {
        "id": {
          "name": "id",
          "type": "integer",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": true
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "lat": {
          "name": "lat",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "long": {
          "name": "long",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {},
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {}
    },
    "organisation_user": {
      "name": "organisation_user",
      "columns": {
        "id": {
          "name": "id",
          "type": "integer",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": true
        },
        "organisation_id": {
          "name": "organisation_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "user_id": {
          "name": "user_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "role": {
          "name": "role",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {},
      "foreignKeys": {
        "organisation_user_organisation_id_organisation_id_fk": {
          "name": "organisation_user_organisation_id_organisation_id_fk",
          "tableFrom": "organisation_user",
          "tableTo": "organisation",
          "columnsFrom": [
            "organisation_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "organisation_user_user_id_user_id_fk": {
          "name": "organisation_user_user_id_user_id_fk",
          "tableFrom": "organisation_user",
          "tableTo": "user",
          "columnsFrom": [
            "user_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {}
    },
    "slot": {
      "name": "slot",
      "columns": {
        "id": {
          "name": "id",
          "type": "integer",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": true
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "start_time": {
          "name": "start_time",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "space_id": {
          "name": "space_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "block_length": {
          "name": "block_length",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 30
        },
        "block_price": {
          "name": "block_price",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "created_at": {
          "name": "created_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "deleted_at": {
          "name": "deleted_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        }
      },
      "indexes": {},
      "foreignKeys": {
        "slot_space_id_space_id_fk": {
          "name": "slot_space_id_space_id_fk",
          "tableFrom": "slot",
          "tableTo": "space",
          "columnsFrom": [
            "space_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {}
    },
    "slot_day_of_month": {
      "name": "slot_day_of_month",
      "columns": {
        "slot_id": {
          "name": "slot_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "day_of_month": {
          "name": "day_of_month",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        }
      },
      "indexes": {},
      "foreignKeys": {},
      "compositePrimaryKeys": {
        "slot_day_of_month_slot_id_day_of_month_pk": {
          "columns": [
            "day_of_month",
            "slot_id"
          ]
        }
      },
      "uniqueConstraints": {}
    },
    "slot_weekday": {
      "name": "slot_weekday",
      "columns": {
        "slot_id": {
          "name": "slot_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "weekday_id": {
          "name": "weekday_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        }
      },
      "indexes": {},
      "foreignKeys": {},
      "compositePrimaryKeys": {
        "slot_weekday_slot_id_weekday_id_pk": {
          "columns": [
            "slot_id",
            "weekday_id"
          ]
        }
      },
      "uniqueConstraints": {}
    },
    "space": {
      "name": "space",
      "columns": {
        "id": {
          "name": "id",
          "type": "integer",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": true
        },
        "organisation_id": {
          "name": "organisation_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "seats": {
          "name": "seats",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "lat": {
          "name": "lat",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "long": {
          "name": "long",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "deleted_at": {
          "name": "deleted_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        }
      },
      "indexes": {},
      "foreignKeys": {
        "space_organisation_id_organisation_id_fk": {
          "name": "space_organisation_id_organisation_id_fk",
          "tableFrom": "space",
          "tableTo": "organisation",
          "columnsFrom": [
            "organisation_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {}
    },
    "space_image": {
      "name": "space_image",
      "columns": {
        "id": {
          "name": "id",
          "type": "integer",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": true
        },
        "space_id": {
          "name": "space_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "key": {
          "name": "key",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "space_image_key_unique": {
          "name": "space_image_key_unique",
          "columns": [
            "key"
          ],
          "isUnique": true
        }
      },
      "foreignKeys": {
        "space_image_space_id_space_id_fk": {
          "name": "space_image_space_id_space_id_fk",
          "tableFrom": "space_image",
          "tableTo": "space",
          "columnsFrom": [
            "space_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {}
    },
    "unavailable": {
      "name": "unavailable",
      "columns": {
        "id": {
          "name": "id",
          "type": "integer",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": true
        },
        "reason": {
          "name": "reason",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "organisation_id": {
          "name": "organisation_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "space_id": {
          "name": "space_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "start_time": {
          "name": "start_time",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "end_time": {
          "name": "end_time",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {},
      "foreignKeys": {
        "unavailable_organisation_id_organisation_id_fk": {
          "name": "unavailable_organisation_id_organisation_id_fk",
          "tableFrom": "unavailable",
          "tableTo": "organisation",
          "columnsFrom": [
            "organisation_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "unavailable_space_id_space_id_fk": {
          "name": "unavailable_space_id_space_id_fk",
          "tableFrom": "unavailable",
          "tableTo": "space",
          "columnsFrom": [
            "space_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {}
    },
    "user": {
      "name": "user",
      "columns": {
        "id": {
          "name": "id",
          "type": "integer",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": true
        },
        "email": {
          "name": "email",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "phone": {
          "name": "phone",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "password_hash": {
          "name": "password_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "email_verified": {
          "name": "email_verified",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "created_at": {
          "name": "created_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "user_email_unique": {
          "name": "user_email_unique",
          "columns": [
            "email"
          ],
          "isUnique": true
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {}
    },
    "weekday": {
      "name": "weekday",
      "columns": {
        "id": {
          "name": "id",
          "type": "integer",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": true
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        }
      },
      "indexes": {},
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {}
    }
  },
  "enums": {},
  "_meta": {
    "schemas": {},
    "tables": {},
    "columns": {}
  }
}

About this issue

  • Original URL
  • State: closed
  • Created 7 months ago
  • Reactions: 5
  • Comments: 35 (13 by maintainers)

Most upvoted comments

I understand if this is a dealbreaker. However, I think this issue could be resolved with the addition of a single line to your snapshot.json.

"compositePrimaryKeys": {
  "slot_day_of_month_slot_id_day_of_month_pk": {
    "columns": [
      "day_of_month",
      "slot_id"
    ],
    "name": "slot_day_of_month_slot_id_day_of_month_pk"
  }
}

I agree it is not a great experience to manually modify generated files, but this resolved the issue for me, thx!

@jam-fran please try drizzle-orm@beta

drizzle-kit@beta fixed the issues for us as well!

This is a bug, I’ll fix it! Thanks for pointing that out

Worked like a charm! Thanks for your help. I made a small donation to buy you a beer for the effort 😃 keep up the good work.

@AndriiSherman Resolved! Thank you so much 😃

just reproduced. going to fix

Had the behavior described here. Then upgraded to your recommended version @AndriiSherman

Now getting: image

The index name of group is unique though. To be sure, i even renamed it to “qweasdqweqw”:

export const groups = pgTable(
  "groups",
  {
    id: serial("id").primaryKey(),
    userId: text("userId")
      .notNull()
      .references(() => users.id),
    name: text("name").notNull(),
  },
  (t) => ({
    idxUser: index("qweasdqweqw").on(t.userId),
  })
);

The error still stays the same.

Was released in drizzle-kit@0.20.11. Should fix this issue. If someone will see the same - please reopen this one and ping me

@jam-fran please try drizzle-orm@beta

After updating to drizzle-kit@0.29.10 I’m also receiving this error, but I’ve confirmed that all of my compositePrimaryKeys have names. I have over 150 snapshot.json files, and all of them are malformed.

Downgrading to version 0.29.9 and running the same generate command results in an error:

We've found duplicated index name across app schema. Please rename your index in either the users table or the table with the duplicated index name

A careful inspection of my latest snapshot.json confirms this is an incorrect error as far as I can tell.

Downgrading again to version 0.29.8 resolves all issues and successfully performs the generation and migration commands.

Below is an example of the simplest snapshot.json file that is malformed when using version 0.29.10. @AndriiSherman any troubleshooting tips would be greatly appreciated!

{
  "version": "5",
  "dialect": "pg",
  "id": "3de4a537-6627-4340-8e80-fdcf2defd9a3",
  "prevId": "8639fbd4-3329-4ff2-8f28-a90250e0bd20",
  "tables": {
    "teams": {
      "name": "teams",
      "schema": "app",
      "columns": {
        "id": {
          "name": "id",
          "type": "serial",
          "primaryKey": true,
          "notNull": true
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "email_domain": {
          "name": "email_domain",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "timezone": {
          "name": "timezone",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {},
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {
        "teams_email_domain_unique": {
          "name": "teams_email_domain_unique",
          "nullsNotDistinct": false,
          "columns": ["email_domain"]
        }
      }
    },
    "users": {
      "name": "users",
      "schema": "app",
      "columns": {
        "id": {
          "name": "id",
          "type": "serial",
          "primaryKey": true,
          "notNull": true
        },
        "email": {
          "name": "email",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "first_name": {
          "name": "first_name",
          "type": "text",
          "primaryKey": false,
          "notNull": true
        },
        "last_name": {
          "name": "last_name",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "avatar_url": {
          "name": "avatar_url",
          "type": "text",
          "primaryKey": false,
          "notNull": false
        },
        "role": {
          "name": "role",
          "type": "user_role",
          "primaryKey": false,
          "notNull": true,
          "default": "'member'"
        },
        "status": {
          "name": "status",
          "type": "user_status",
          "primaryKey": false,
          "notNull": true,
          "default": "'active'"
        },
        "is_tracked": {
          "name": "is_tracked",
          "type": "boolean",
          "primaryKey": false,
          "notNull": true,
          "default": false
        },
        "team_id": {
          "name": "team_id",
          "type": "integer",
          "primaryKey": false,
          "notNull": true
        },
        "created_at": {
          "name": "created_at",
          "type": "timestamp with time zone",
          "primaryKey": false,
          "notNull": true,
          "default": "now()"
        }
      },
      "indexes": {
        "email_idx": {
          "name": "email_idx",
          "columns": ["email"],
          "isUnique": true
        }
      },
      "foreignKeys": {
        "users_team_id_teams_id_fk": {
          "name": "users_team_id_teams_id_fk",
          "tableFrom": "users",
          "tableTo": "teams",
          "columnsFrom": ["team_id"],
          "columnsTo": ["id"],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {
        "users_email_unique": {
          "name": "users_email_unique",
          "nullsNotDistinct": false,
          "columns": ["email"]
        }
      }
    }
  },
  "enums": {
    "user_role": {
      "name": "user_role",
      "values": {
        "admin": "admin",
        "member": "member"
      }
    },
    "user_status": {
      "name": "user_status",
      "values": {
        "active": "active",
        "deleted": "deleted"
      }
    }
  },
  "schemas": {},
  "_meta": {
    "schemas": {},
    "tables": {},
    "columns": {}
  }
}

Ideally you shouldn’t change snapshot and it always should be handled by drizzle-kit