Closed sacdallago closed 5 years ago
Seems like the seeding is called before the table creation
Note, the seeding worker also complains:
[Thu Jun 06 2019 10:38:48] [ERROR] [SeedingWorker] SEEDIG ERROR { SequelizeDatabaseError: relation "users" does not exist
....
[Thu Jun 06 2019 10:38:48] [LOG] [SeedingWorker] seeding done.
On restarting the app, you get:
[Thu Jun 06 2019 10:39:52] [LOG] [SeedingWorker] CONNECTING TO postgres://***:***@127.0.0.1:5432/mecu
[Thu Jun 06 2019 10:39:52] [WARN] [SeedingWorker] No private/config.js found... continuing with default config
[Thu Jun 06 2019 10:39:53] [LOG] [SeedingWorker] Connection has been established successfully.
[Thu Jun 06 2019 10:39:53] [LOG] [SeedingWorker] doing seeding...
[Thu Jun 06 2019 10:39:53] [LOG] [SeedingWorker] seeding done.
But nothing is seeded
Note: when it fails, the tables won't be created. when restarted, the tables will be created. This makes me think that as mentioned above, the seeding is done before creating the tables
Confirmed: It would be necessary to move this code: https://github.com/sacdallago/mecu/blob/develop/app/server/slaveWorker.js#L194 before the migration worker starts if no version is declared --> means the database needs to be created and no migration is necessary, only initialization. If some version of the database exists, then do migrations...
Just as a reference: the seeding is done in one case when !version
, in another case when version < 2
. If version is undefined
, comparison to anything else renders none
, thus that statement doesn't get executed. Better solution: use a switch statement which follows through, e.g.: https://github.com/sacdallago/mecu/pull/52/files#diff-ef76af1f02471541934bd0fdf2a6095eR37
-When creating a new database docker instance via:
by starting the app on the db, you get the following error:
Also: the other SQL seeding statements don't get executed (but maybe I'm doing something wrong?)