Answer the question
In order to leave comments, you need to log in
What is the correct way to use PostgreSQL in Rails?
There is a rail project and a PG database. A test branch was created based on the development branch, in which migrations to the database were made. After deleting this branch without merging it into the development branch, all changes from the test branch remained in the database, and when trying to create tables in the development branch that were in the test branch, it gives an error about the existence of such a table.
As far as I understand, the reason is that the PG database is not located in the project's db/ folder, and is not tracked by git.
How to properly organize everything to avoid such problems?
Answer the question
In order to leave comments, you need to log in
The standard way to work with PG in development with branches that have a different database structure is:
At the same time, do not forget to add the minimum set of database records necessary for development in db/seeds.rb
And if you want to simplify life, then install zsh and a plugin for rake, rails and use aliases:rdd; rdc; rdm; rds
the reason is that the PG database is not in the project's db/ folder, and is not tracked by git.
Manually delete these tables (whose migrations occurred in another branch). Or if you need them along with the data and you have migrations written for them in development, then you can manually mark these migrations as completed in the schema_migrations table .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question