Open disco-infinex opened 1 month ago
@disco-infinex,
I don't typically work with datasets regularly in support that have views so I hadn't gotten a chance to try and verify what you had shared here yet but today I was working with one and definitely experienced the same behavior you described above so I'll see if I can work on some potential improvements for this over the next week or two.
Looks like I had experienced the issue as well last year: https://github.com/planetscale/cli/issues/701
I'm pretty sure this should be fixable however so I'll review both issues and focus on trying to get a solution put together for this 👍.
These commands will (seemingly?) never work if the branch being dumped/restored contains a view:
There are several bugs contributing to this:
pscale database dump
command inexplicably takes a copy of data from views. Dumping a view schema makes sense but the data is necessarily derived from the other data in the DB, including it just takes up space and slows the dump process. Strange this is even allowed, let alone the default.--overwrite-tables
flag "will attempt to DROP TABLE before restoring" but has no effect on views. As such, attempting to restore a DB dump that includes views will error withError: failed to restore database: target: [...].-.primary: vttablet: rpc error: code = AlreadyExists desc = Table '[...]' already exists
even when--overwrite-tables
is used. This can be avoided by deleting the views*-schema.sql
file in the dump dir but better would be if the--overwrite-tables
flag also apply to views or, I suppose, you could add a separate--overwrite-views
flag.error restoring {"error": "target: [...].-.primary: vttablet: rpc error: code = Unknown desc = Column 'id' is not updatable
. Again, deleting the data files dumped for the view works around the issue but surely the restore command could be smart enough to know the "table" in question is view and skip it.Some of this could be avoided if either the dump or restore commands had a way to exclude specific tables/views. The
--tables
argument works but is painful to use if you have 100 tables and a few views that need excluding every single time.