9

I'm migrating my app from MySQL to Postgres. If I do a rake db:schema:load, it loads fine into Postgres, and all my tests pass.

If I do rake db:migrate:reset, then an integer column that I had previously set to have :limit => 1 is set to have :limit => 2.

My migration sets it like so:

t.integer "foo", :limit => 1, :null => false

Is it simply a matter of Postgres having a lower minimum size?

2 Answers 2

6

The smallint type in PostgreSQL occupies two byte and accepts numbers from -32768 to +32767.

There is no tinyint like in MySQL that occupies 1 byte and accepts numbers from -128 to 127.

Sign up to request clarification or add additional context in comments.

Comments

3

Postgres doesn't provide a 1-byte integer type. The smallest datatype for integer is the 2-byte smallint.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.