drift
drift copied to clipboard
More memory/temporary table support
Is your feature request related to a problem? Please describe. Drift now supports in-memory/temporary DB but as standalone DB. I need to use in-memory/temporary DB as second DB(attached DB).
Describe the solution you'd like One possible way for it is
Add option to disable auto table creation for in-memory/temporary table and option to specify schema for Table
@DisaleAutoCreate
class InMemoryDbTable extends Table (
@override
String get schema = 'aux1'; // or schema() method like alias()
)
@override
int get schemaVersion => 1;
@override
MigrationStrategy get migration {
return MigrationStrategy(beforeOpen: (details) async {
await customStatement('ATTACH DATABASE ':memory:' AS aux1'); // attach to memory DB
InMemoryDbTable.createTable(); // manually create table
});
}
thx.
Related to #1366 and #1159.
I agree that we should support something like this, but we need a clear way to separate the different schemas. Maybe this could also be a part of the database annotation:
@DriftDatabase(
tables: [Users],
additionalSchemas: {
'aux1': [InMemoryDbTable]
},
)