dwyl / learn-postgresql

🐘 Learn how to use PostgreSQL and Structured Query Language (SQL) to store and query your relational data. 🔍
212 stars 23 forks source link

how to load an existing schema into a new database when starting an existing app for the first time #26

Closed nelsonic closed 5 years ago

nelsonic commented 7 years ago

We need a good way of loading an existing database schema and/or data into a database when a new member of the team is booting the app for the first time this is obvs also applicable to testing your app in CI ... 🍏

The way we have done this is: create_table.js but we don't think is a particularly good way of doing it... 🤔

If anyone has a simpler more effective or faster way of doing this please let us know! ❤️ ✅

AnianZ commented 7 years ago

I usually use migrations and seeds with knex.js. That makes changes to the database more portable and forces me to keep them revertible. Currently I don't have an active CI pipeline yet but it works great for provisioning vagrantfiles.

If a query builder like knex is too much for you, there sure is a simpler solution for migrations and seeds with pure SQL or just implement your own.

nelsonic commented 5 years ago

Ecto Migrations/Seeds have us covered with this. 💧 ❤️ ✅