mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-19 07:50:52 +01:00
102 lines
3.5 KiB
Dart
102 lines
3.5 KiB
Dart
import 'package:powersync/powersync.dart';
|
|
|
|
const todosTable = 'todos';
|
|
const musclesTable = 'exercises_muscle';
|
|
const logItemsTable = 'nutrition_logitem';
|
|
|
|
/*
|
|
Postgres:
|
|
wger@localhost:wger> \d nutrition_logitem;
|
|
+----------------+--------------------------+--------------------------------------------+
|
|
| Column | Type | Modifiers |
|
|
|----------------+--------------------------+--------------------------------------------|
|
|
| id | integer | not null generated by default as identity |
|
|
| datetime | timestamp with time zone | not null |
|
|
| comment | text | |
|
|
| amount | numeric(6,2) | not null |
|
|
| ingredient_id | integer | not null |
|
|
| plan_id | integer | not null |
|
|
| weight_unit_id | integer | |
|
|
| meal_id | integer | |
|
|
+----------------+--------------------------+--------------------------------------------+
|
|
*/
|
|
// these are the same ones as in postgres, except for 'id', because that is implied
|
|
Schema schema = const Schema([
|
|
Table(
|
|
logItemsTable,
|
|
[
|
|
Column.text('datetime'),
|
|
Column.text('comment'),
|
|
Column.integer('amount'),
|
|
Column.integer('ingredient_id'),
|
|
Column.integer('plan_id'),
|
|
Column.integer('weight_unit_id'),
|
|
Column.integer('meal_id'),
|
|
],
|
|
indexes: [
|
|
// Index('plan', [IndexedColumn('plan_id')])
|
|
],
|
|
),
|
|
Table(
|
|
todosTable,
|
|
[
|
|
Column.text('list_id'),
|
|
Column.text('created_at'),
|
|
Column.text('completed_at'),
|
|
Column.text('description'),
|
|
Column.integer('completed'),
|
|
Column.text('created_by'),
|
|
Column.text('completed_by'),
|
|
],
|
|
indexes: [
|
|
// Index to allow efficient lookup within a list
|
|
Index('list', [IndexedColumn('list_id')]),
|
|
],
|
|
),
|
|
Table(
|
|
'lists',
|
|
[
|
|
Column.text('created_at'),
|
|
Column.text('name'),
|
|
Column.text('owner_id'),
|
|
],
|
|
),
|
|
Table(
|
|
'exercises_muscle',
|
|
[Column.text('name'), Column.text('name_en'), Column.text('is_front')],
|
|
),
|
|
]);
|
|
|
|
// post gres columns:
|
|
// todos:
|
|
// id | created_at | completed_at | description | completed | created_by | completed_by | list_id
|
|
// lists:
|
|
// id | created_at | name | owner_id
|
|
|
|
// diagnostics app:
|
|
/*
|
|
new Schema([
|
|
new Table({
|
|
name: 'lists', // same as flutter
|
|
columns: [
|
|
new Column({ name: 'created_at', type: ColumnType.TEXT }),
|
|
new Column({ name: 'name', type: ColumnType.TEXT }),
|
|
new Column({ name: 'owner_id', type: ColumnType.TEXT })
|
|
]
|
|
}),
|
|
new Table({
|
|
name: 'todos', // misses completed_at and completed_by, until these actually get populated with something
|
|
columns: [
|
|
new Column({ name: 'created_at', type: ColumnType.TEXT }),
|
|
new Column({ name: 'description', type: ColumnType.TEXT }),
|
|
new Column({ name: 'completed', type: ColumnType.INTEGER }),
|
|
new Column({ name: 'created_by', type: ColumnType.TEXT }),
|
|
new Column({ name: 'list_id', type: ColumnType.TEXT })
|
|
]
|
|
})
|
|
])
|
|
|
|
Column.text('completed_at'),
|
|
Column.text('completed_by'),
|
|
*/
|