~ read.

Postgres Table Names can only be 63 characters

Today I was experimenting with generating database views. For debugging purposes I was including the rails model name and a random string as the name of the view.

To my chagrin, the table name was being truncated and not including the random string, causing some name collisions when running the report multiple times.

The culprit: name limit for identifiers in Postgres.

Trying to add a longer name will simply truncate it to the max length.

Easy solution: Add the random string to the beginning of the table name, not the end.

More information is available in the docs