Is there a string length limit in heroku when inserting data into a postgresql active records database in ruby?

Viewed 16

I am currently running into a problem where on my local machine, I can create and insert a record into a table called Devices but on my heroku deploy, I cannot create a record if the length of my identifier and push_token are too long. The device table migration I am using is pasted below.

class CreateDevices < ActiveRecord::Migration[6.1]
    def change
      create_table :devices do |t|
        t.string :identifier, null: false
        t.string :push_token, null: false
      end
    end
end

I tried a simple test with an endpoint to see if records were created with

get "/test/devices/:device_id/:push_tokens" do
     Device.create(identifier: params[:device_id], push_token: params[:push_tokens])
     puts "device_count is"
     puts Device.count
  end

On my local machine, if i set params[:device_id] and params[:push_tokens] to for example, 278b5d5668b7e2df3b686e0c0d19a0b9 and 1319f7e0f6dd345304c5e8e84e5ec3f52213b8f485e4783861b476373f000dde respectively the active record updates and the device count updates with it. However if i try these values on the heroku deploy, the device count is not updated and no record is created. I am struggling to figure out whether this is a problem with my postgresql plan on heroku, if my code is not waiting for the record to be created or something entirely different.

2022-09-23T13:47:45.399683+00:00 heroku[router]: at=info method=GET path="/test/devices/123456789123456789/123456789123456789" host=japsoc-passes-server-2.herokuapp.com request_id=21779202-b9b6-4e02-9195-6ead6cc63ba6 fwd="147.12.186.203" dyno=web.1 connect=0ms service=9ms status=200 bytes=191 protocol=https
2022-09-23T13:47:45.394194+00:00 app[web.1]: device_count is
2022-09-23T13:47:45.395126+00:00 app[web.1]: 8
2022-09-23T13:47:59.284900+00:00 heroku[router]: at=info method=GET path="/test/devices/123456789123456789123456789/123456789123456789123456789" host=japsoc-passes-server-2.herokuapp.com request_id=04ef6dab-71c3-4237-b52f-bf2ea16576f0 fwd="147.12.186.203" dyno=web.1 connect=0ms service=7ms status=200 bytes=191 protocol=https
2022-09-23T13:47:59.279643+00:00 app[web.1]: device_count is
2022-09-23T13:47:59.280339+00:00 app[web.1]: 9
2022-09-23T13:48:17.720446+00:00 heroku[router]: at=info method=GET path="/test/devices/123456789123456789123456789123456789/123456789123456789123456789123456789" host=japsoc-passes-server-2.herokuapp.com request_id=1c221b82-f142-44a0-b0ec-774a8515365a fwd="147.12.186.203" dyno=web.1 connect=0ms service=9ms status=200 bytes=191 protocol=https
2022-09-23T13:48:17.715182+00:00 app[web.1]: device_count is
2022-09-23T13:48:17.715917+00:00 app[web.1]: 10
2022-09-23T13:48:35.566064+00:00 heroku[router]: at=info method=GET path="/test/devices/123456789123456789123456789123456789123456789/123456789123456789123456789123456789123456789" host=japsoc-passes-server-2.herokuapp.com request_id=2539f65b-7f82-42dc-9c4e-c078b93412d1 fwd="147.12.186.203" dyno=web.1 connect=0ms service=6ms status=200 bytes=191 protocol=https
2022-09-23T13:48:35.560941+00:00 app[web.1]: device_count is
2022-09-23T13:48:35.561519+00:00 app[web.1]: 11
2022-09-23T13:49:00.943300+00:00 heroku[router]: at=info method=GET path="/test/devices/123456789123456789123456789123456789123456789123456789/123456789123456789123456789123456789123456789123456789" host=japsoc-passes-server-2.herokuapp.com request_id=01acc954-8cf9-4327-8e84-b1958298b14d fwd="147.12.186.203" dyno=web.1 connect=0ms service=8ms status=200 bytes=191 protocol=https
2022-09-23T13:49:00.937948+00:00 app[web.1]: device_count is
2022-09-23T13:49:00.938685+00:00 app[web.1]: 12
2022-09-23T13:49:52.814962+00:00 heroku[router]: at=info method=GET path="/test/devices/123456789123456789123456789123456789123456789123456789/123456789123456789123456789123456789123456789123456789123456789123456789" host=japsoc-passes-server-2.herokuapp.com request_id=c834c2df-b822-4796-b8ae-ab29cce6bdc2 fwd="147.12.186.203" dyno=web.1 connect=0ms service=5ms status=200 bytes=191 protocol=https
2022-09-23T13:49:52.809811+00:00 app[web.1]: device_count is
2022-09-23T13:49:52.810427+00:00 app[web.1]: 12

I did some testing with the endpoint on the heroku deploy and it seems that at some point, if the string is too long for either the identifier or the push_token, no record is created but i still receive a status 200. I would greatly appreciate any help on this matter!

0 Answers
Related