9
votes
4answers
2k views

How to add sequences to a migration and use them in a model?

I want to have a "Customer" Model with a normal primary key and another column to store a custom "Customer Number". In addition, I want the db to handle default Customer Numbers. I think, defining a ...
9
votes
1answer
587 views

Use Postgres Multiple Schema Database in Rails

I'm developing a multitenant app following this article. The problem is when I run all migrations the first time. In schema.rb file are only the tables for the public schema but what happend with the ...
5
votes
1answer
269 views

Error trying to load structure with rake db:structure:load, “schema_migration” does not exist

I'm running rake db:structure:load but after loading all structure it fails to insert versions at schema_migrations. Looks like PostgreSQL don't know about recently created tables. Already googled ...
3
votes
2answers
4k views

has_many & belongs_to migration with foreign keys and database constraints in postgres?

I've searched several questions about migrations and their answers, but I didn't find a satisfactory solution. I want to use simple has_many and belongs_to relationships like class User < ...
3
votes
1answer
2k views

Rails: rake db:create:all (could not connect to server)

follow the screencasts http://railscasts.com/episodes/342-migrating-to-postgresql?autoplay=true up to the steps of "rake db:create:all" and get error: could not connect to server: No such file or ...
1
vote
2answers
261 views

rails 4 undefined method `sql_type' in migration

I have following migration: class CreateTariffs < ActiveRecord::Migration def change create_table :tariffs do |t| t.string :name t.decimal :amount, precision: 10, scale: 6, ...
1
vote
0answers
143 views

failing migrations : PG::ProtocolViolation Rails

I just updated to rails4 and realized that my db roles and database was somehow not setup. So I dropped the db and re-created the app_development db and the roles. Now I am trying to run rake ...
0
votes
1answer
64 views

Rails: last migration reapplied

Sometimes rake db:migrate tries to run migrations which have already been successfully migrated (without any errors). When I check the schema_migrations table, the repetitive migration is not there. ...
0
votes
0answers
60 views

no records showing after migration to postgres

Just followed the "Migrating to PostgreSQL" Railscast, migrating my local sqlite3 database to postgres: here is my database.yml file: development: adapter: postgresql encoding: unicode ...