Public
Like1
migrate-sqlite
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Migrate tables, views, indexes, and triggers from your Val Town account-based (global) database to a val-scoped database.
Import migrate from this val and call it with your configuration:
import migrate from "https://esm.town/v/nbbaier/migrate-sqlite/migrate.ts";
await migrate({
tables: ["users", "posts"],
views: ["active_users"], // optional
});
- Tables — schema and all row data (specify in
tables) - Autoincrement sequences — automatically detected for tables using
AUTOINCREMENT - Views — specify in
views(optional, defaults to[]) - Indexes — automatically discovered for the listed tables
- Triggers — automatically discovered for the listed tables
- Safe to re-run: uses
IF NOT EXISTSfor tables/views/indexes andDROP + CREATEfor triggers - Row inserts use
INSERT OR IGNOREto skip duplicates on re-runs - Table/column names are quoted to handle special characters
- Rows are inserted in chunks of 100
When running and testing your migration, the SQLite Explorer val (for global db) and built-in SQLite admin panel (for val db) are helpful.