drizzle-team / drizzle-kit-mirror

Docs and issues repository for drizzle-kit
290 stars 17 forks source link

[Studio] TypeError: Cannot read properties of undefined (reading 'tables') #546

Open byroncoetsee opened 1 month ago

byroncoetsee commented 1 month ago

Starting studio in CLI works (no errors thrown) but browsing to local.drizzle.studio shows the error TypeError: Cannot read properties of undefined (reading 'tables') Has been working fine until suddenly it didn't. generate, introspect both work fine correctly so the DB is available and the connection works.

package.json

"dependencies": {
    "@headlessui/react": "^2.1.2",
    "@heroicons/react": "^2.1.5",
    "@nextui-org/react": "^2.4.6",
    "@nextui-org/tooltip": "^2.0.39",
    "@stripe/react-stripe-js": "^2.7.3",
    "@stripe/stripe-js": "^4.2.0",
    "@supabase/supabase-js": "^2.45.1",
    "@types/lodash": "^4.17.7",
    "@types/node": "^22.3.0",
    "aws-sdk": "^2.1674.0",
    "dotenv": "^16.4.5",
    "drizzle-orm": "^0.33.0",
    "lodash": "^4.17.21",
    "next": "14.2.5",
    "next-auth": "^5.0.0-beta.19",
    "node-cache": "^5.1.2",
    "openai": "^4.55.7",
    "pdfreader": "^3.0.4",
    "pg": "^8.12.0",
    "react": "^18.3.1",
    "react-dom": "^18.3.1",
    "stripe": "^16.7.0",
    "uuid": "^10.0.0",
    "zustand": "^4.5.4"
  },
  "devDependencies": {
    "@types/pg": "^8.11.6",
    "@types/react": "^18",
    "@types/react-dom": "^18",
    "@types/uuid": "^10.0.0",
    "drizzle-kit": "^0.24.0",
    "eslint": "^8",
    "eslint-config-next": "14.2.5",
    "postcss": "^8",
    "tailwindcss": "^3.4.10",
    "typescript": "^5"
  }

Here is the error context:

{
  "drizzle-playground": {
    "state": {
      "editorHight": 300,
      "currentFile": "sql",
      "drizzleValue": null,
      "sqlValue": null,
      "showRecordsAsJson": false,
      "drizzleResult": "{\"json\":null}",
      "sqlResult": "{\"json\":null}"
    },
    "version": 0
  },
  "drizzle-global": {
    "state": {
      "showCounts": true,
      "flatSchemas": false
    },
    "version": 0
  },
  "drizzle-version": "2.0.1",
  "drizzle-custom-theme-ids": [],
  "drizzle-db-3890abdeb6be9fcc2d04a4248c1c2b402b2f20a0efab9c4ea924b4c183fe1f20": {
    "state": {
      "styleMode": "default",
      "currentPage": "main",
      "filterViews": {},
      "isSidebarOpen": true,
      "isShowSidebarContent": true,
      "filtersVisible": false,
      "sidebarWidth": 268,
      "currentSchema": {
        "name": "public",
        "tables": [],
        "views": []
      },
      "currentTable": {
        "name": "invoices",
        "columns": [
          {
            "name": "id",
            "type": "number",
            "hasDefault": true,
            "isUnique": false,
            "hasCustomDefault": false,
            "notNull": true,
            "_type": "serial",
            "width": 120,
            "visible": true
          },
          {
            "name": "uuid",
            "type": "string",
            "default": "gen_random_uuid()",
            "hasDefault": true,
            "isUnique": true,
            "hasCustomDefault": false,
            "notNull": false,
            "_type": "uuid",
            "width": 120,
            "visible": true
          },
          {
            "name": "created_at",
            "type": "date",
            "default": "now()",
            "hasDefault": true,
            "isUnique": false,
            "hasCustomDefault": false,
            "notNull": true,
            "_type": "timestamp",
            "width": 250,
            "visible": true
          },
          {
            "name": "user_id",
            "type": "number",
            "hasDefault": false,
            "isUnique": false,
            "hasCustomDefault": false,
            "notNull": true,
            "_type": "integer",
            "width": 120,
            "visible": true
          },
          {
            "name": "email_id",
            "type": "string",
            "hasDefault": false,
            "isUnique": false,
            "hasCustomDefault": false,
            "notNull": true,
            "_type": "varchar",
            "width": 120,
            "visible": true
          },
          {
            "name": "attachment_id",
            "type": "string",
            "hasDefault": false,
            "isUnique": false,
            "hasCustomDefault": false,
            "notNull": true,
            "_type": "varchar",
            "width": 195,
            "visible": true
          },
          {
            "name": "invoice_number",
            "type": "string",
            "hasDefault": false,
            "isUnique": false,
            "hasCustomDefault": false,
            "notNull": false,
            "_type": "varchar",
            "width": 210,
            "visible": true
          },
          {
            "name": "amount",
            "type": "number",
            "hasDefault": false,
            "isUnique": false,
            "hasCustomDefault": false,
            "notNull": false,
            "_type": "double precision",
            "width": 120,
            "visible": true
          },
          {
            "name": "paid",
            "type": "boolean",
            "hasDefault": false,
            "isUnique": false,
            "hasCustomDefault": false,
            "notNull": false,
            "_type": "boolean",
            "width": 120,
            "visible": true
          },
          {
            "name": "ignored",
            "type": "boolean",
            "hasDefault": false,
            "isUnique": false,
            "hasCustomDefault": false,
            "notNull": false,
            "_type": "boolean",
            "width": 120,
            "visible": true
          },
          {
            "name": "recipient_name",
            "type": "string",
            "hasDefault": false,
            "isUnique": false,
            "hasCustomDefault": false,
            "notNull": false,
            "_type": "text",
            "width": 210,
            "visible": true
          },
          {
            "name": "bank_name",
            "type": "string",
            "hasDefault": false,
            "isUnique": false,
            "hasCustomDefault": false,
            "notNull": false,
            "_type": "text",
            "width": 135,
            "visible": true
          },
          {
            "name": "account_number",
            "type": "string",
            "hasDefault": false,
            "isUnique": false,
            "hasCustomDefault": false,
            "notNull": false,
            "_type": "text",
            "width": 210,
            "visible": true
          },
          {
            "name": "branch_code",
            "type": "string",
            "hasDefault": false,
            "isUnique": false,
            "hasCustomDefault": false,
            "notNull": false,
            "_type": "text",
            "width": 165,
            "visible": true
          },
          {
            "name": "currency",
            "type": "string",
            "hasDefault": false,
            "isUnique": false,
            "hasCustomDefault": false,
            "notNull": false,
            "_type": "text",
            "width": 120,
            "visible": true
          },
          {
            "name": "pop_email",
            "type": "string",
            "hasDefault": false,
            "isUnique": false,
            "hasCustomDefault": false,
            "notNull": false,
            "_type": "text",
            "width": 135,
            "visible": true
          }
        ],
        "primaryKeys": [],
        "type": "table",
        "id": "invoices",
        "relations": [
          {
            "name": "user",
            "type": "one",
            "table": "invoices",
            "schema": "public",
            "columns": [
              "user_id"
            ],
            "refTable": "users",
            "refSchema": "public",
            "refColumns": [
              "id"
            ],
            "visible": true
          }
        ],
        "filters": [],
        "sort": null,
        "pagination": {
          "limit": 50,
          "offset": 0
        },
        "records": [],
        "createdRecords": [],
        "editedFields": [],
        "schema": "public",
        "historyId": "Gq6TlugU1Sx3_R8Y-miHt",
        "executionTime": 159
      }
    },
    "version": 0
  }
}
dvrfluxchat commented 1 month ago

Same issue for me as well

TypeError: Cannot read properties of undefined (reading 'tables') at https://local.drizzle.studio/index.js:12873:27177 at Array.forEach () at https://local.drizzle.studio/index.js:12873:27062 at Array.forEach () at https://local.drizzle.studio/index.js:12873:27021 at Array.forEach () at sii (https://local.drizzle.studio/index.js:12873:26986) at tAl (https://local.drizzle.studio/index.js:13147:11192)

0.33.0  - drizzle-orm version

0.24.0 - drizzle-kit version

louishugens commented 1 month ago

Same issue here also:

TypeError: Cannot read properties of undefined (reading 'tables') at https://local.drizzle.studio/index.js:12873:27177 at Array.forEach (<anonymous>) at https://local.drizzle.studio/index.js:12873:27062 at Array.forEach (<anonymous>) at https://local.drizzle.studio/index.js:12873:27021 at Array.forEach (<anonymous>) at sii (https://local.drizzle.studio/index.js:12873:26986) at tAl (https://local.drizzle.studio/index.js:13147:11192)

with-key commented 4 weeks ago

i have same issue..

abhimskywalker commented 4 weeks ago

I am facing the same issue. Additionally this happens when connecting to Supabase remote db. If i run same migrations on a local db, it works perfectly.

In fact I have been using a hack to load https://local.drizzle.studio/ pointed to local db first so it loads fine. Then I change the env variable to remote db and restart drizzle studio (without reloading the browser tab), and for all interactions on any table now it works perfectly fine even on remote db! 😄

Probably an issue only in downloading and parsing the schema somewhere it seems...

Wkasel commented 4 weeks ago

Same ^^

MarshallARoss commented 4 weeks ago

Same ^^

palmer8 commented 4 weeks ago

Same ^^

MarshallARoss commented 4 weeks ago

Looks fixed now y'all

louishugens commented 4 weeks ago

Looks fixed now y'all

Seems it is. working for me now. We need to know where was the issue. I believe it is on Supabase side as I tried with a Neon db and it was ok

with-key commented 3 weeks ago

good! very well!