Skip to main content

All Questions

0 votes
0 answers
71 views

Creating a partitioned table with Rails 7.2 and Postgres

I need to create a Postgres table partitioned by range. The partitioning approach is essential because the table will need to store large volumes of data and be queried frequently. The plan is to set ...
fs314's user avatar
  • 129
1 vote
1 answer
65 views

Get record if search term is in one of its related tables related tables in Active Record

Apologies of the title is convoluted but thats basically what I want to do. I have a Table, Building, that is Related to a Table Named Residents, and those Residents can have many Photos and other ...
WoodlandDev's user avatar
3 votes
3 answers
190 views

Remove null bytes for every ActiveRecord string attributes

I have a Rails application using Postgres as the database. Postrgres does not accept strings containing null bytes (example: "a \u0000 b"). Trying to save such data leads to the following ...
lmtaq's user avatar
  • 520
0 votes
0 answers
70 views

Intermittent Data Sync Issue Between Postgres and Neo4j in Ruby on Rails Application

I have a Ruby on Rails application that uses both Postgres and Neo4j databases. For certain records, data is first saved to Postgres, and then a callback is triggered to update the Neo4j database. ...
Lorenz's user avatar
  • 785
0 votes
1 answer
58 views

Query on JSON object keys in ActiveRecord/Postgresql

I have a json column in an Answer table in a rails app; document. I'm trying to write a scope which returns true if the document is empty, or if it contains only one of two specific keys. With ruby we ...
Phil Brockwell's user avatar
0 votes
1 answer
73 views

Relationship problem: there is no unique constraint matching given keys for referenced table

I'm trying to implement partitioning in PostgreSQL. The problem is that one partitioned table references another partitioned table. There is also a third regular table that also references the ...
Colibri's user avatar
  • 1,205
0 votes
0 answers
43 views

PostgresSQL/Ruby: How to get results for a nested SQL table?

I am running some custom SQL on on of my rails models because I need an aggregated result based on previous scopes. events = Event.where(...).where(...).joins(...) subquery = events.select(" (...
Megan Nelson's user avatar
0 votes
0 answers
91 views

Syntax error when rails tries to create ar_internal_metadata?

after upgrating from rails 5.2 to rails 6.1 and ruby 2.7.2 to 3.3.5 I'm facing some weird errors syntax errors when running the initial migration. The application runs fine and even run the migrations ...
xSlok's user avatar
  • 599
1 vote
2 answers
79 views

Inserting or merging time-ordered records

I have a table containing weather information for various locations. Each location is identified by an identifier station_id, and each kind of information is identified by a string (e.g. wind_speed, ...
Spiros's user avatar
  • 2,366
0 votes
1 answer
52 views

Rails 6 active record time zone search issues

My rails 6.0.3 application works on a postgres database and it has an order_datetime column(timestamp without time zone) and Configured time_zone to Kolkata in application.rb. It is +5.30 hours ahead ...
Manivannan Jeganathan's user avatar
0 votes
1 answer
62 views

I have a rails app with a Postgres db and 4 mysql dbs - how can I wrap queries to all dbs in transactions and not just the primary (Postgres) db?

Basically, I have a rails app that has one Postgres database as the primary and reads and writes to both it and 4 independent mysql databases. Transactional tests work just fine when testing behavior ...
Eric's user avatar
  • 159
0 votes
0 answers
99 views

Using test_prof before_all recipe with manual connection switching in multiple db setup

I am using test-prof gem with before_all recipe to create all the necessary records for the suite and run a heavy service afterwards. Yet I'm running into a problem when a block of queries is executed ...
potashin's user avatar
  • 44.6k
0 votes
2 answers
171 views

How to optimize performance and speed up loading data from database?

I have a database table cars that has close to 500k records. I was facing issues with long loading times to load data from this table. @cars = Car.order('created_at DESC').paginate(page: params[:page],...
user984621's user avatar
  • 48.6k
0 votes
0 answers
44 views

Rails Active Record query joins and merge get Ids

User -> Has many cats Vaccinations -> has many cats Cat -> belongs to vaccination User::CatRecords is a namespaced ActiveRecord model -> belongs to cat This is what I have tried so far ...
Manav's user avatar
  • 679
1 vote
0 answers
76 views

how can we use model object method in rails select query

I have two models, first one is User with attributes first_name, last_name and second one is Organization with attribute partner_level which is enum {standard: 'standard',standard_plus: 'standard_plus'...
Rana. Amir's user avatar

15 30 50 per page
1
2 3 4 5
164