hapipal / hapipal.com

This is the home of hapipal.com
https://hapipal.com
MIT License
12 stars 3 forks source link

Migrations mismatch with pre-populated database in getting started tutorial #60

Open devinivy opened 3 years ago

devinivy commented 3 years ago

The pre-populated database provided for learning/convenience creates a difficult snag when used in the context of the getting started tutorial: because the migrations tracked in the db by knex wont match the names of the migrations created during the getting started tutorial, knex will believe the migrations directory is corrupted. For example, upon server start:

> PATH_TO_DATABASE=riddles.db node server
[exiting] Fatal exception: Error: The migration directory is corrupt, the following files are missing: 20180420011654_add-riddles.js

I believe one of the main reasons to advertise the pre-populated db was to make it simple to have some persisted riddles without needing to create and re-create them across server starts while playing with the tutorial, so hopefully our solution will cater to this.

openam commented 3 years ago

Could you do the prepopulated, but delete the knex tables? That way it will start properly. It would probably cause issues when people start adding migration scripts for the existing tables.

It could be said that if you don't want to go through the migration stuff here is a prepopulated table...

Another option would be to create a part of the tutorial that goes over seeding a database with knex like @zemccartney mentioned.

zemccartney commented 3 years ago

@openam hey, thanks for that. I don't know for sure, but I'm guessing you're spot on that deleting any knex-related tables would lead to conflicts. Keeping the database clean, solely the purview of whoever's working through the tutorial, seems the safest way to go here.

And I totally agree addressing this issue will mean adding / revising the tutorial to walk people to new to pal through our approach