magic_local_storage 1.0.1
magic_local_storage: ^1.0.1 copied to clipboard
SQLite local database layer for Magic apps: DB and Schema facades, migrations, seeders, factories, query builder and sync.
Changelog #
All notable changes to this project will be documented in this file.
1.0.1 - 2026-11-15 #
Fixed #
- Saving a
useLocalmodel, or callinginsertorupdate, on a table that does not exist yet now throws aStateErrornaming the table instead of reporting success, sosave()returnsfalsebefore the migration ran; a table created later is seen without a restart. - Plain table and column names (letters, digits and underscores, optionally dotted such as
users.idorcache.items) are quoted inSchema.create,Schema.table,Schema.drop,Schema.renameand the query builder'swhere,orderBy,value,pluck,insertandupdate, so a column namedorder,grouporindexworks; any other text, such aslower(email)orname COLLATE NOCASE, is written as given, so a caller passing an expression sees no change. A string default containing'no longer breaksCREATE TABLE, and a schema-qualified table such ascache.itemsis now read and written. whererejects an operator outside=,==,!=,<>,<,<=,>,>=,like,not like,glob,not glob,match,isandis not, andorderBya direction other thanascordesc, with anArgumentError, so neither can carry SQL.- A connection opened by the provider treats a double-quoted name as an identifier only, so a mistyped quoted column fails with
no such columninstead of matching a string literal. where(column, '=', null)no longer binds'='as the value: anullvalue compiles toIS NULLwith=,==,isor two arguments and toIS NOT NULLwith!=,<>oris not, and throws anArgumentErrorwith any other operator.make:migration,make:seederandmake:factoryrefuse a name with.., an empty segment, a backslash or a colon instead of writing outsidelib/database/.- Corrected the sqlite3 repository links and the wasm compatibility notes, the example's web setup, and the
llms.txtsetup sample, which now callsMagic.init. - The documentation and the agent skill now match the code: a write to a table that does not exist throws a
StateError(sosave()returnsfalseon a local-only model andFactory.create()throws) rather than dropping every attribute or answering0; withuseLocalanduseRemoteboth on,findfalls back to the API on a miss andallonly when the local read throws;SyncFeed.runlogs only a thrown exception, not a refused HTTP response; the testing guide no longer listsHttp.unfake()among the statics a container reset leaves; and the web wasm is always requested at the origin root/sqlite3.wasm, so an app served from a sub-path must still serve the file there. - The agent skill listing is shorter.
Changed #
- The
make:migrationskeleton'sdown()throwsUnsupportedErroruntil you write the rollback, so a rollback can no longer forget a migration that is still applied. local_storage:installdownloads thesqlite3.wasmof thesqlite3release the project resolved, falling back to 3.9.1 when it cannot read it.- The package page is
https://anilcancakir.com/magic/local_storageand the documentation links sit underhttps://anilcancakir.com/magic/docs/local_storage.
1.0.0 - 2026-11-14 #
Added #
- First release. The SQLite layer for Magic apps, moved out of
magiccore 1.0.0. A model withuseLocal => trueneeds this package. DBandSchemafacades on one local SQLite connection, withMigrationandMigrator,Seeder,FactoryandSeeding.run, and aQueryBuilderbehindModel.query().QueryModelStore, the storage behind everyuseLocalmodel, replaceable at theLocalModelStorecontainer key.SyncFeedandSyncLedger: a push-then-pull sync skeleton.DatabaseServiceProviderand thedatabaseConfigconfig factory.- Generators
make:migration,make:seederandmake:factory, andlocal_storage:install, which downloadsweb/sqlite3.wasmfor a project with aweb/folder. - A
dowelplugin provider (MagicLocalStorageDowelProvider) thatdart run magic:dowel plugin:install magic_local_storageregisters. - Native through FFI, web through
sqlite3.wasm. Built onsqlite33.9.1,path_provider^2.1.6,path^1.9.1 anddowel^1.0.0. Requires Dart 3.13, Flutter 3.47 andmagic^1.0.0.