synw / sqlcool

Easy and reactive Sqlite for Flutter
MIT License
163 stars 28 forks source link

Add or modify fields #17

Closed byteslaves closed 4 years ago

byteslaves commented 4 years ago

Hello, I am very happy to use the plugin you developed, it is really great. But I encountered a small problem. How do I add or modify fields after the data table is initialized to make the old data table be overwritten? Thank you

synw commented 4 years ago

Glad that you enjoy the package. There is no support for migrations in Sqlcool. I made tests with a persistent schema to enable this but it is not worth it, adding too much complexity. The internally declared database schema representation is actually only a read only in memory value.

You have to manage this in sql directly. Or there is a migrations module for Sqlite but I never tested it. The solution depends on what you want to achieve

byteslaves commented 4 years ago

Glad that you enjoy the package. There is no support for migrations in Sqlcool. I made tests with a persistent schema to enable this but it is not worth it, adding too much complexity. The internally declared database schema representation is actually only a read only in memory value.

You have to manage this in sql directly. Or there is a migrations module for Sqlite but I never tested it. The solution depends on what you want to achieve

@synw Hello, now I rebuild the database by modifying the path every time I modify the field, but how do I clear the old database? Now it seems because the old database has reported an error. I / flutter (5867): # 0 Database.initDb. (package: test_app / cmomon / database.dart: 57: 7) I / flutter (5867): # 1 _rootRunUnary (dart: async / zone.dart: 1134: 38) I / flutter (5867): # 2 _CustomZone.runUnary (dart: async / zone.dart: 1031: 19) I / flutter (5867): # 3 _FutureListener.handleError (dart: async / future_impl.dart: 157: 20) I / flutter (5867): # 4 Future._propagateToListeners.handleError (dart: async / future_impl.dart: 692: 47) I / flutter (5867): # 5 Future._propagateToListeners (dart: async / future_impl.dart: 713: 24) I / flutter (5867): # 6 Future._completeError (dart: async / future_impl.dart: 532: 5) I / flutter (5867): # 7 _AsyncAwaitCompleter.completeError (dart: async-patch / async_patch.dart: 38: 15) I / flutter (5867): # 8 Db.init (package: sqlcool / src / database.dart) I / flutter (5867): I / flutter (5867): # 9 Database.initDb (package: test_app / cmomon / database.dart: 50: 10) I / flutter (5867): # 10 _SplashPageState._initAsync (package: test_app / main.dart: 157: 16) I / flutter (5867): I / flutter (5867): # 11 _SplashPageState.initState (package: test_app / main.dart: 136: 5) I / flutter (5867): # 12 StatefulElement._firstBuild (package: flutter / src / widgets / framework.dart: 4355: 58) I / flutter (5867): # 13 ComponentElement

synw commented 4 years ago

now I rebuild the database by modifying the path every time I modify the field

What you are doing is not clear, you should give more context and explanations about your goals and the code you use to get good help for your issue

synw commented 4 years ago

Op is not even responding, he might have solved his problem, closing