Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

SQLITE_CONSTRAINT: NOT NULL constraint failed #15

Open
dawnerd opened this issue Jun 4, 2022 · 1 comment
Open

SQLITE_CONSTRAINT: NOT NULL constraint failed #15

dawnerd opened this issue Jun 4, 2022 · 1 comment
Assignees
Labels
issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: v3-MongoDB to v3-SQL status: pending reproduction Waiting for free time to reproduce the issue, or more information

Comments

@dawnerd
Copy link
Contributor

dawnerd commented Jun 4, 2022

Running Mongo -> Sql

[Error: insert into `haunts` (`Name`, `Slug`, `created_at`, `id`, `updated_at`) values ('SeaWorld San Diego’s Howl-O-Scream', 'sea-world-san-diego-s-howl-o-scream', '2021-03-14 22:04:41.060', 1, '2021-03-14 22:06:44.220') - SQLITE_CONSTRAINT: NOT NULL constraint failed: haunts.CurrentlyOperating] {
  errno: 19,
  code: 'SQLITE_CONSTRAINT'
}

Schema for that:

{
  "kind": "collectionType",
  "collectionName": "haunts",
  "info": {
    "name": "Haunts",
    "description": ""
  },
  "options": {
    "increments": true,
    "timestamps": true,
    "draftAndPublish": false
  },
  "attributes": {
    "Name": {
      "type": "string",
      "required": true
    },
    "Slug": {
      "type": "uid",
      "targetField": "Name",
      "required": true
    },
    "AlternativeNames": {
      "type": "component",
      "repeatable": true,
      "component": "common.alternative-names"
    },
    "CurrentlyOperating": {
      "type": "boolean",
      "default": true,
      "required": true
    },
    "Geo": {
      "type": "json"
    },
    "IsTempClosed": {
      "type": "boolean",
      "default": false,
      "required": true
    },
    "Park": {
      "model": "parks"
    },
    "NiceName": {
      "type": "string"
    },
    "MainPhoto": {
      "model": "file",
      "via": "related",
      "allowedTypes": [
        "images"
      ],
      "plugin": "upload",
      "required": false
    },
    "CoverPhoto": {
      "model": "file",
      "via": "related",
      "allowedTypes": [
        "images"
      ],
      "plugin": "upload",
      "required": false
    },
    "Gallery": {
      "collection": "file",
      "via": "related",
      "allowedTypes": [
        "images"
      ],
      "plugin": "upload",
      "required": false
    },
    "Sections": {
      "type": "dynamiczone",
      "components": [
        "text.section-header",
        "text.text"
      ]
    },
    "Region": {
      "model": "regions",
      "via": "Haunts"
    },
    "OpeningDate": {
      "type": "string"
    },
    "ClosedDate": {
      "type": "string"
    },
    "HauntYears": {
      "via": "Haunt",
      "collection": "haunt-years"
    },
    "Attribute": {
      "type": "component",
      "repeatable": true,
      "component": "attraction.attribute"
    }
  }
}
@dawnerd
Copy link
Contributor Author

dawnerd commented Jun 4, 2022

So luckily the data that was failing was experimental and I was able to just remove it and continue on.

I did run into another issue:

Error: Empty .update() call detected! Update data does not contain any values to update. This will result in a faulty query. Table: ride_credits. Columns: Attraction.
    at QueryCompiler_SQLite3._prepUpdate (/home/troy/Projects/migration-scripts/v3-mongodb-v3-sql/node_modules/knex/lib/query/querycompiler.js:1213:13)
    at QueryCompiler_SQLite3.update (/home/troy/Projects/migration-scripts/v3-mongodb-v3-sql/node_modules/knex/lib/query/querycompiler.js:193:29)
    at QueryCompiler_SQLite3.toSQL (/home/troy/Projects/migration-scripts/v3-mongodb-v3-sql/node_modules/knex/lib/query/querycompiler.js:73:29)
    at Builder.toSQL (/home/troy/Projects/migration-scripts/v3-mongodb-v3-sql/node_modules/knex/lib/query/querybuilder.js:83:44)
    at ensureConnectionCallback (/home/troy/Projects/migration-scripts/v3-mongodb-v3-sql/node_modules/knex/lib/execution/internal/ensure-connection-callback.js:4:30)
    at Runner.ensureConnection (/home/troy/Projects/migration-scripts/v3-mongodb-v3-sql/node_modules/knex/lib/execution/runner.js:272:20)
    at async Runner.run (/home/troy/Projects/migration-scripts/v3-mongodb-v3-sql/node_modules/knex/lib/execution/runner.js:30:19)
    at async run (/home/troy/Projects/migration-scripts/v3-mongodb-v3-sql/index.js:275:15)

I just wrapped that bit of code in a try just to get it to complete. Seems there's some old data somewhere that is missing a connection, nbd really.

Apart from this the script seems to have been successful at migrating ~4k documents with complex relations. Good job ya'll! 🎉

@derrickmehaffy derrickmehaffy added source: v3-MongoDB to v3-SQL status: pending reproduction Waiting for free time to reproduce the issue, or more information severity: medium If it breaks the basic use of the product but can be worked around issue: bug Issue reporting a bug labels Jun 4, 2022
@derrickmehaffy derrickmehaffy moved this to To be reviewed in v3 to v4 Migration Project Jun 4, 2022
@derrickmehaffy derrickmehaffy self-assigned this Jul 11, 2022
@derrickmehaffy derrickmehaffy moved this from To be reviewed to Reviewed in v3 to v4 Migration Project Jul 11, 2022
@derrickmehaffy derrickmehaffy moved this from Reviewed to To be reviewed in v3 to v4 Migration Project Jul 11, 2022
@derrickmehaffy derrickmehaffy self-assigned this Aug 24, 2022
@derrickmehaffy derrickmehaffy moved this from To be reviewed to In progress in v3 to v4 Migration Project Sep 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: v3-MongoDB to v3-SQL status: pending reproduction Waiting for free time to reproduce the issue, or more information
Projects
Status: In progress
Development

No branches or pull requests

3 participants