#db:generate does nothing

16 messages · Page 1 of 1 (latest)

stark birch
#

I accidentally dropped my module tables and decided to recreate the migrations, so I deleted the migration files and snapshot as well. Now, when I try to generate migrations again, it says, Skipped. Database is up-to-date for module.

#

It also creates a new snapshot file with the content:

{
  "tables": [],
  "namespaces": []
}
stark birch
#

It doesn’t work for a specific module, but it doesn’t throw any exceptions.

honest sun
#

try npx medusa db:generate (specificModule).

stark birch
#

npx medusa db:generate (specificModule)
I’m doing exactly that.

honest sun
#

it's only going to compare current model code to db, if there is no difference no migrations generated.

stark birch
#

There are no tables in the database. I’ve dropped them.

honest sun
#

then run npx medusa db:migrate

stark birch
#

It doesn’t do anything because db:generate doesn’t generate the correct migration files. It thinks the tables are still present and displays Skipped. Database is up-to-date for module

honest sun
#

if you've dropped all tables, npx medusa db:migrate recreates them all against in the db.

#

double check you're connecting to the correct db

stark birch
#

npx medusa db:migrate will recreate all tables ONLY if the migrations are generated beforehand. However, npx medusa db:generate [specificModule] currently doesn’t create the necessary migrations, that’s the main issue here.

stark birch
#

packages/core/utils/src/modules-sdk/migration-scripts/migration-generate.ts

method buildGenerateMigrationScript get empty models array

#

packages/core/modules-sdk/src/loaders/utils/load-internal.ts line 448

stark birch