| Path: | doc/release_notes/5.7.0.txt |
| Last Update: | Sat Jun 02 02:04:22 +0000 2018 |
This affects all internal use of the Integer class as a generic database type, so that methods like primary_key and foreign_key also default to using a 64-bit integer type when using this extension.
DB.create_table(:table){Integer :id, identity: true}
# CREATE TABLE "table" ("id" integer GENERATED BY DEFAULT AS IDENTITY)
If you want to disallow using a user provided value when inserting, or updating you can use a value of :always:
DB.create_table(:table){Integer :id, identity: :always}
# CREATE TABLE "table" ("id" integer GENERATED ALWAYS AS IDENTITY)
DB.create_table(:table){primary_key :id}
# Sequel 5.7.0+ and PostgreSQL 10.2+
# CREATE TABLE "table" ("id" integer
# GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY)
# Older Sequel version or older PostgreSQL version
# CREATE TABLE "table" ("id" serial PRIMARY KEY)
Identity columns fix many issues that serial columns have, in addition to being the SQL standard way to support auto incrementing columns.