|
1 | 1 | import 'package:powersync/powersync.dart';
|
2 | 2 |
|
3 |
| -const todosTable = 'todos'; |
4 |
| -const musclesTable = 'exercises_muscle'; |
5 |
| -const logItemsTable = 'nutrition_logitem'; |
| 3 | +const tableMuscles = 'exercises_muscle'; |
| 4 | +const tableLogItems = 'nutrition_logitem'; |
| 5 | +const tableNutritionPlans = 'nutrition_nutritionplan'; |
| 6 | +const tableMeals = 'nutrition_meal'; |
| 7 | +const tableMealItems = 'nutrition_mealitem'; |
6 | 8 |
|
7 |
| -/* |
8 |
| -Postgres: |
9 |
| -wger@localhost:wger> \d nutrition_logitem; |
10 |
| -+----------------+--------------------------+--------------------------------------------+ |
11 |
| -| Column | Type | Modifiers | |
12 |
| -|----------------+--------------------------+--------------------------------------------| |
13 |
| -| id | integer | not null generated by default as identity | |
14 |
| -| datetime | timestamp with time zone | not null | |
15 |
| -| comment | text | | |
16 |
| -| amount | numeric(6,2) | not null | |
17 |
| -| ingredient_id | integer | not null | |
18 |
| -| plan_id | integer | not null | |
19 |
| -| weight_unit_id | integer | | |
20 |
| -| meal_id | integer | | |
21 |
| -+----------------+--------------------------+--------------------------------------------+ |
22 |
| -*/ |
23 |
| -// these are the same ones as in postgres, except for 'id', because that is implied |
24 | 9 | Schema schema = const Schema([
|
25 | 10 | Table(
|
26 |
| - logItemsTable, |
| 11 | + tableMuscles, |
| 12 | + [Column.text('name'), Column.text('name_en'), Column.text('is_front')], |
| 13 | + ), |
| 14 | + Table( |
| 15 | + tableNutritionPlans, |
| 16 | + [ |
| 17 | + Column.text('creation_date'), |
| 18 | + Column.text('description'), |
| 19 | + Column.integer('has_goal_calories'), |
| 20 | + Column.integer('user_id'), |
| 21 | + Column.integer('only_logging'), |
| 22 | + Column.integer('goal_carbohydrates'), |
| 23 | + Column.integer('goal_energy'), |
| 24 | + Column.integer('goal_fat'), |
| 25 | + Column.integer('goal_protein'), |
| 26 | + Column.integer('goal_fiber'), |
| 27 | + ], |
| 28 | + ), |
| 29 | + Table( |
| 30 | + tableLogItems, |
27 | 31 | [
|
28 | 32 | Column.text('datetime'),
|
29 | 33 | Column.text('comment'),
|
30 | 34 | Column.integer('amount'),
|
31 | 35 | Column.integer('ingredient_id'),
|
32 | 36 | Column.integer('plan_id'),
|
33 | 37 | Column.integer('weight_unit_id'),
|
34 |
| - Column.integer('meal_id'), |
| 38 | + Column.integer('meal_id'), // optional |
35 | 39 | ],
|
36 | 40 | indexes: [
|
37 | 41 | // Index('plan', [IndexedColumn('plan_id')])
|
38 | 42 | ],
|
39 | 43 | ),
|
40 | 44 | Table(
|
41 |
| - todosTable, |
| 45 | + tableMeals, |
42 | 46 | [
|
43 |
| - Column.text('list_id'), |
44 |
| - Column.text('created_at'), |
45 |
| - Column.text('completed_at'), |
46 |
| - Column.text('description'), |
47 |
| - Column.integer('completed'), |
48 |
| - Column.text('created_by'), |
49 |
| - Column.text('completed_by'), |
50 |
| - ], |
51 |
| - indexes: [ |
52 |
| - // Index to allow efficient lookup within a list |
53 |
| - Index('list', [IndexedColumn('list_id')]), |
| 47 | + Column.integer('order'), |
| 48 | + Column.text('time'), |
| 49 | + Column.integer('plan_id'), |
| 50 | + Column.text('name'), |
54 | 51 | ],
|
55 | 52 | ),
|
56 | 53 | Table(
|
57 |
| - 'lists', |
| 54 | + tableMealItems, |
58 | 55 | [
|
59 |
| - Column.text('created_at'), |
60 |
| - Column.text('name'), |
61 |
| - Column.text('owner_id'), |
| 56 | + Column.integer('order'), |
| 57 | + Column.integer('amount'), |
| 58 | + Column.integer('ingredient_id'), |
| 59 | + Column.integer('meal_id'), |
| 60 | + Column.integer('weight_unit_id'), |
62 | 61 | ],
|
63 | 62 | ),
|
64 |
| - Table( |
65 |
| - 'exercises_muscle', |
66 |
| - [Column.text('name'), Column.text('name_en'), Column.text('is_front')], |
67 |
| - ), |
68 | 63 | ]);
|
69 |
| - |
70 |
| -// post gres columns: |
71 |
| -// todos: |
72 |
| -// id | created_at | completed_at | description | completed | created_by | completed_by | list_id |
73 |
| -// lists: |
74 |
| -// id | created_at | name | owner_id |
75 |
| - |
76 |
| -// diagnostics app: |
77 |
| -/* |
78 |
| -new Schema([ |
79 |
| - new Table({ |
80 |
| - name: 'lists', // same as flutter |
81 |
| - columns: [ |
82 |
| - new Column({ name: 'created_at', type: ColumnType.TEXT }), |
83 |
| - new Column({ name: 'name', type: ColumnType.TEXT }), |
84 |
| - new Column({ name: 'owner_id', type: ColumnType.TEXT }) |
85 |
| - ] |
86 |
| - }), |
87 |
| - new Table({ |
88 |
| - name: 'todos', // misses completed_at and completed_by, until these actually get populated with something |
89 |
| - columns: [ |
90 |
| - new Column({ name: 'created_at', type: ColumnType.TEXT }), |
91 |
| - new Column({ name: 'description', type: ColumnType.TEXT }), |
92 |
| - new Column({ name: 'completed', type: ColumnType.INTEGER }), |
93 |
| - new Column({ name: 'created_by', type: ColumnType.TEXT }), |
94 |
| - new Column({ name: 'list_id', type: ColumnType.TEXT }) |
95 |
| - ] |
96 |
| - }) |
97 |
| -]) |
98 |
| -
|
99 |
| - Column.text('completed_at'), |
100 |
| - Column.text('completed_by'), |
101 |
| -*/ |
0 commit comments