Title: `void db reset` does not drop views: MySQL reset and seed fail when a migration creates one · Issue #421 · voidzero-dev/void · GitHub
Open Graph Title: `void db reset` does not drop views: MySQL reset and seed fail when a migration creates one · Issue #421 · voidzero-dev/void
X Title: `void db reset` does not drop views: MySQL reset and seed fail when a migration creates one · Issue #421 · voidzero-dev/void
Description: Problem The app has a migration that creates a view. void db migrate works. Then void db reset (or void db seed) fails when it re-applies that migration. Dialect View over a table View that reads no table D1 / SQLite (local) works works ...
Open Graph Description: Problem The app has a migration that creates a view. void db migrate works. Then void db reset (or void db seed) fails when it re-applies that migration. Dialect View over a table View that reads n...
X Description: Problem The app has a migration that creates a view. void db migrate works. Then void db reset (or void db seed) fails when it re-applies that migration. Dialect View over a table View that reads n...
Opengraph URL: https://github.com/voidzero-dev/void/issues/421
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`void db reset` does not drop views: MySQL reset and seed fail when a migration creates one","articleBody":"## Problem\n\nThe app has a migration that creates a view. `void db migrate` works. Then `void db reset` (or `void db seed`) fails when it re-applies that migration.\n\n| Dialect | View over a table | View that reads no table |\n| --- | --- | --- |\n| D1 / SQLite (local) | works | works |\n| PostgreSQL | works | **fails** |\n| MySQL | **fails** | **fails** |\n\nMySQL 8.4:\n\n```\n$ void db reset --yes\n■ migration 0001_view.sql failed: Table 'user_names' already exists\n```\n\nPostgreSQL 17, with `CREATE VIEW app_info AS SELECT 'v1'::text AS version;`:\n\n```\n$ void db reset --yes\n■ migration 0002_const_view.sql failed: relation \"app_info\" already exists\n```\n\nOn MySQL the database is then left half reset. `users` and `_void_migrations` are created again, the old view is still there, and only `0000_init.sql` is recorded. `void db migrate` and later resets fail with the same error until the view is dropped by hand.\n\nThis is older than #413: 6b47270e3 fails the same way (`■ Table 'user_names' already exists`).\n\n## Repro\n\n`void.config.ts` has `database: 'mysql'`, and `.env` has `DATABASE_URL=mysql://root:root@127.0.0.1:3306/app`.\n\n```sql\n-- db/migrations/0000_init.sql\nCREATE TABLE users (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255) NOT NULL);\n-- db/migrations/0001_view.sql\nCREATE VIEW user_names AS SELECT name FROM users;\n```\n\n```\nvoid db migrate # ✓ Applied 2 migrations.\nvoid db reset --yes # ■ migration 0001_view.sql failed: Table 'user_names' already exists\n```\n\n## Cause\n\nReset lists only tables, drops them, and then runs every migration file again. Views are never listed:\n\n```\nvoid db reset (MySQL)\n list tables WHERE table_type = 'BASE TABLE' -> users, _void_migrations\n (user_names is a VIEW, so it is not listed)\n DROP TABLE users, _void_migrations MySQL keeps the view\n CREATE TABLE IF NOT EXISTS _void_migrations empty, so every file is pending\n 0000_init.sql ok\n 0001_view.sql CREATE VIEW user_names ... -> ER 1050 already exists\n```\n\nLine numbers are on main, b58300ff8:\n\n- MySQL: `packages/void/src/cli/db.ts:606-618` runs\n `SELECT table_name AS table_name FROM information_schema.tables WHERE table_schema = DATABASE() AND table_type = 'BASE TABLE'`,\n then ``DROP TABLE IF EXISTS `\u003cname>` `` for each row. MySQL does not drop a view when its base table is dropped.\n- PostgreSQL: `packages/void/src/cli/db.ts:584-589` runs\n `SELECT tablename FROM pg_tables WHERE schemaname = 'public'`, then `DROP TABLE IF EXISTS \"\u003cname>\" CASCADE`.\n CASCADE removes views that depend on those tables. A view that does not depend on one stays.\n- Reapply: `db.ts:622` → `packages/void/src/migrations/runner-mysql.ts:163-179`. For PostgreSQL, `db.ts:590` → `runner-pg.ts:52-67`.\n- `void db seed` calls the same `resetDatabase()` (`db.ts:654`).\n- D1 / SQLite deletes the database file instead (`db.ts:631-633`), so it is not affected.\n\n## Suggested fix\n\n- MySQL: query `information_schema.tables` without the `BASE TABLE` filter. Run `DROP VIEW IF EXISTS` for rows of type `VIEW`, and `DROP TABLE IF EXISTS` for the rest. Keep skipping `_void_migration_lock`.\n- PostgreSQL: also drop the views and materialized views in `public` (`pg_views`, `pg_matviews`) with `CASCADE`.\n\nWorkaround today: drop the view by hand, then run `void db reset` again.\n\n🤖 Generated with [Claude Code](https://claude.com/claude-code)\n\nhttps://claude.ai/code/session_0123r5HnanmW2VUrZ7VWDufH\n","author":{"url":"https://github.com/Brooooooklyn","@type":"Person","name":"Brooooooklyn"},"datePublished":"2026-10-14T11:00:46Z","url":"https://github.com/voidzero-dev/void/issues/421"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:75935d0c-bac8-2f78-8f3d-c6385b03e053 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9B98:1B8129:1BF9D16:25FF73C:6AFB9702 |
| html-safe-nonce | 02e7df5055bed04339030333109a089303b7bcd0a8b5ff04bbff9e526269b2fb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5Qjk4OjFCODEyOToxQkY5RDE2OjI1RkY3M0M6NkFGQjk3MDIiLCJ2aXNpdG9yX2lkIjoiNTMxMjM3OTQ5MTgzNjQ2Njk0NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7fbeab84394e957dde7e426d539fa499ef134a1c6a0db2959c324ac7e12d1f8b |
| hovercard-subject-tag | issue:5846592209 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/voidzero-dev/void/421/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f97ec118437b522479b0b0564c65ca645ccfadb4e6ec18ab7e4b9ced05f8bc7d/voidzero-dev/void/issues/421 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f97ec118437b522479b0b0564c65ca645ccfadb4e6ec18ab7e4b9ced05f8bc7d/voidzero-dev/void/issues/421 |
| og:image:alt | Problem The app has a migration that creates a view. void db migrate works. Then void db reset (or void db seed) fails when it re-applies that migration. Dialect View over a table View that reads n... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Brooooooklyn |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4f01efe06174a5ba6342fd58e42d02295e0675bedbb465d6bef2dbaec8e46556 |
| turbo-cache-control | no-preview |
| go-import | github.com/voidzero-dev/void git https://github.com/voidzero-dev/void.git |
| octolytics-dimension-user_id | 149750581 |
| octolytics-dimension-user_login | voidzero-dev |
| octolytics-dimension-repository_id | 1164437080 |
| octolytics-dimension-repository_nwo | voidzero-dev/void |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1164437080 |
| octolytics-dimension-repository_network_root_nwo | voidzero-dev/void |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | a52db8866b6543b4e83730cd6a6b1360f1a9e4dc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width