Rails is a cross-platform model-view-controller-centric application framework for Ruby. Use this tag for database-related Rails questions.

learn more… | top users | synonyms

2
votes
2answers
44 views

Efficient schema to handle time interval queries on a huge table?

We have huge table (+10 millions rows) where we aggregate the values by a using a time interval search on a Datetime column. And right now, to build single page on our app, we are querying this table ...
0
votes
1answer
31 views

MySQL database has way too many connections

I have a MySQL version 5.7.12 database that has 4 applications running against them. Two of these applications are single webservers running Rails apps. The other two applications are also Rails ...
0
votes
0answers
26 views

Are read replicas affected by heavy writtings in master?

This is my problem: Sometimes one long lasting query (>60 secs, and I have a lot of those) which is always a SELECT makes my whole application stops working properly up until the query is solved. ...
0
votes
0answers
32 views

Postgres hstore or jsonb to store many to many relations

There is a table 'Products' with columns (id, tile, price, description, shop_id, timestamps) Column price and shop_id are dynamic. The rest of column are static. Also there is a table 'Shops' with ...
0
votes
2answers
38 views

MySQL create index with LOCK=NONE still locks a table

I have the following MySQL RoR Migrations: class ReindexRpushNotification < ActiveRecord::Migration def up execute("DROP INDEX `index_rpush_notifications_multi` ON rpush_notifications;") ...
0
votes
0answers
4 views

How can I clear my database on Heroku?

I have an application that I deployed to Heroku. Everytime I try to sign-up, it gives me and error that tells me my password is invalid. I've type in everything correctly and I'm sure I've never ...
0
votes
1answer
38 views

In Rails: How is existing data affected by data type change?

I'm working on a Rails app and would like to change the datatype for an existing column. It's currently a DateTime type, and I want to change it to a Date type. I found a way to do this here, but in ...
1
vote
1answer
44 views

Postgres: querying jsonb array with an array

My products table has a jsonb column called 'specs'. This specs hash will often have an array field, let's call it 'spec_options'. When querying this table, I need to find any product that has ...
0
votes
1answer
36 views

Source of error on psql data load

Upon importing a file derived from rails establishment, psql is hitting the error of foreign key constraints: ERROR: insert or update on table "documents" violates foreign key constraint "...
0
votes
1answer
36 views

Database Design - I have a question regarding joining tables

Forgive me for my dumb question but I am new to Ruby on Rails and data design. We all have to start somewhere right? Well my question is that I want to build a database for a Truck driving company. It ...
0
votes
1answer
110 views

MySQL: How to decrease sleep process's time out?

When I run 'show processlist;', then I get so many sleep processes. I set wait_timeout and interactive_timeout to 60 in my.cnf. But, sleep process is not died when time 60 on processlist. I found ...
0
votes
0answers
19 views

Proper handling of errors on pg_restore

Following the execution of a pg_dump -Fc the follow-up pg_restore is generating errors. Under pg_restore -c -v -1 -d nothing gets written as Error while PROCESSING TOC: for the specific motive of ...
0
votes
0answers
49 views

Syntax for setting postgresql schema in ruby script

The following script runs, but executes only partially rubber.sudo_script "create_master_db", <<-ENDSCRIPT sudo -i -u postgres psql -c "#{create_user_cmd}" sudo -i -...
0
votes
0answers
44 views

accessing postgis extension capabilities

The context is pertinent as it demonstrates behaviour different than other (more manual) successful attempts. Deploying a rails application with postgres and postgis extension to AWS EC2 instance, ...
3
votes
1answer
110 views

Inventory management in Rails

I'm creating a inventory management app in rails. I have an User Table and a Recipe table, there is also some tables with types of material (pens, sharpies, paper, and so on). Because there is a lot ...
0
votes
0answers
37 views

Adding postgis geometry with rake task

I have a postgres table test with a geometry column: Column | Type | Modifiers --------------...
1
vote
1answer
157 views

PostgreSQL: restore a record from a backup

We have a Rails app backed by a PostgreSQL DB and hosted on Heroku. We recently had a bug that deleted some (very few before we caught it) records. Excuse my ignorance but is there a straightforward ...
0
votes
1answer
43 views

What postgres sync solution should I use to duplicate production, but read it from another application?

I'm a little out of my league with my current problem, but I'm looking for a solution where the following conditions are met: My production database reads and writes as it currently does My ...
2
votes
1answer
2k views

How to convert time without time zone to timestamp without time zone in PostgreSQL?

I received this error when trying to alter a column of type time to type timestamp: PG::CannotCoerce: ERROR: cannot cast type time without time zone to timestamp without time zone It's not ...
2
votes
1answer
134 views

Copying database to different hard disk

Total noob at database administration here, excuse my ignorance. I have a server running a Rails application that's using PostgreSQL. The database is saved on drive /z/, which seems to have filled up....
2
votes
1answer
818 views

PostgreSQL 9.3 Amazon RDS gives error while using UUID-OSSP extension for generating uuid

I have created DB instance on RDS and used below function it gaves error while with same postgreSQL version on local development machine works fine. create or replace function uuid() returns uuid as '...
0
votes
0answers
84 views

Multi-Tiered Database Design Issue

I am trying to build the multi-level model as demonstrated. When a user creates a campaign they will select some categories and some metros from tables Category and Metro. Those selections will then ...
1
vote
0answers
334 views

On Heroku in production, how can I copy database A to database B on command?

From my local terminal, I can use the following commands to do what I need to do: heroku pgbackups:capture --expire heroku pgbackups:restore charcoal --confirm max-kiosk However, I want to do this ...
0
votes
1answer
237 views

Duplicate Relationships in Rails/MySQL Healthcare Application

Overview of the Application I am building a Ruby on Rails application to organize medications, using MySQL. The goal of this application is to provide dosage specific treatment recommendations, and ...
0
votes
1answer
908 views

While importing 150 GB file on Amazon RDS, why connection is failing?

I am having Postgres database dump file of 150 GB on Amazon EC2 instance. While dumping the data on RDS from EC2 server I am getting error. The output of the command is as given below. It's giving ...
0
votes
0answers
322 views

Can’t connect to local PostgresSQL server

I have the Postres app installed an running on my Mac. And it has worked beautifully. I don’t know what changed, but now I cannot connect to it from Rails, PG Commander, PG Admin or the command psql -...
1
vote
1answer
88 views

Why add indexes to these columns in the Database?

I am trying to get my head around this code. It's from the Rails Tutorial Book and is part of the process of making a twitter like application. class CreateRelationships < ActiveRecord::...