480 questions
4
votes
1
answer
935
views
How do I migrate an ActiveRecord model attribute from json to jsonb?
What should the migration look like? I would like to take advantage of the jsonb array querying technique.
0
votes
1
answer
2k
views
LPAD & RPAD with parameter
I have a problem, I have a function in postgres, to generate headers that will be used to generate a more complex report.
There all good. For the structure of the header, I leave spaces left or right ...
5
votes
3
answers
36k
views
How to Connect to Docker Postgres Container from Host Machine
I put together a Rails dev environment by following instructions from
https://docs.docker.com/compose/rails/
It works, but I am unable to connect to the Postgres server from the host machine. I am ...
0
votes
1
answer
54
views
Issues with understanding multiple joins
I have the following tables:
users
____________
| id |
| first_name |
|____________|
pre_task_plans
____________
| id |
| creator_id | (fk user_id)
|____________|
...
0
votes
1
answer
1k
views
Backup taken from pgadmin is smaller than backup taken from pgdump
Hello experts I am using postgres 9.5 . When I take a backup from pgadmin it has 950 MB size but when i take the same db backup from pgdump.exe command the backup size is with 7.5 GB. I am confused ...
0
votes
1
answer
393
views
Rails Tenant schema switching with background jobs not working
Setting up a scheduled rake task using Whenever gem.
Required to switch to a specific schema (Using Apartment gem in my project)
Code in config/schedule.rb
env :PATH, ENV['PATH']
env :GEM_PATH, ENV[...
1
vote
1
answer
125
views
update query not working on Heroku using cloud 9 command line
I have the following tables:
and the users table contains the following columns:
I am trying to run the following statement:
UPDATE users SET isTeacher = 'TRUE' WHERE id = '2';
but I am getting the ...
0
votes
1
answer
96
views
Find conversations between users
I need an ActiveRecord query to find conversations for current_user and any another user
Conversations can have many users. I need to set users ids in that query(it can be two or more users).
class ...
0
votes
1
answer
65
views
How can I calculate locationGeo space in pgadmin 3 type with PostGIS functions?
My table name is map and I have latitude(double),longitude(double) and locationGeo(geometry) columns. I want to use a function to automatically compute the LocationGeo value using the given latitude ...
1
vote
1
answer
1k
views
Postgres Trigger in specified time
Hello expert I am working in banking software vendor company and we are working in PostgreSQL database due to load of work in office time(pick hour) I want to execute some function in specified time(...
1
vote
1
answer
632
views
How to send PG binary data from the Rails controller?
I have a Postgres database with PostGIS extension and some geo-data in it. I need to generate tiles with custom SQL queries (using ST_... functions), that returns binary data (bytea, like \...
1
vote
1
answer
339
views
Why is Postgres double-quoting the first function identifier when I set a default function for a column?
I have a legacy table with a default expression in a Rails project. This expression picks a random four-digit number and converts it to a string. During my tests I have been typing this exact ...
1
vote
2
answers
2k
views
Why does this Postgres Select Query work in the local Docker Container but not on Amazon RDS Postgres?
My team has a local development environment that contains a Ruby on Rails app that connects to a Postgres database to retrieve some information about airports and use that to make further queries. ...
0
votes
1
answer
56
views
Rails ActiveRecord Behaviour?
I wanted to understand how ActiveRecord works in the following scenario.
@messages = Message.joins(:users).where("some condition").uniq
now if i use @messages.sum(:url_view_count)
I see the query is ...
1
vote
3
answers
14k
views
SQL Count digits in a string
I have a table of the following information.
description: adjkfa34kj34kj33j4k3jk4
description: adfkjjkdf34_3434kjkjkj3
description: akjdfkjadfkjadkjfkjadfj
description: 34394394093040930949039
How ...