Skip to content

[BUG]: drizzle-kit wants to delete sqlite internal stats tables #3979

@fpw

Description

@fpw

Report hasn't been filed before.

  • I have verified that the bug I'm about to report hasn't been filed before.

What version of drizzle-orm are you using?

0.38.4

What version of drizzle-kit are you using?

0.30.2

Other packages

No response

Describe the Bug

Hi all,

when using PRAGMA optimize in sqlite, it will create internal statistic tables that are used by the query planner. As an example, one of the tables is named sqlite_stat1 as documented in the linked manual section.

Undesired behavior: When using drizzle-kit push, it treats these tables as unknown and asks to delete them:

[✓] Pulling schema from database...                                                                          
 Warning  Found data-loss statements:
· You're about to delete sqlite_stat1 table with 28 items

THIS ACTION WILL CAUSE DATA LOSS AND CANNOT BE REVERTED

Do you still want to push changes?

Desired result: In my opinion, drizzle-kit should ignore all internal tables, views and other objects when analyzing the schema. As documented here, it is quite easy to identify internal objects: Their names will begin with "sqlite_" and it's not possible for user code to create schema objects with this prefix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions