-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mapping Identity column to Serial instead of using Sequences #102
Comments
Hello @issafram The PostgreSQL implementation makes it the same: https://www.postgresql.org/docs/11/datatype-numeric.html#DATATYPE-SERIAL If I manually create a table using a serial, I will get a sequence: thibaut=# CREATE TABLE testtable ( value serial PRIMARY KEY);
CREATE TABLE
thibaut=# \d testtable
Table « public.testtable »
Colonne | Type | Collationnement | NULL-able | Par défaut
---------+---------+-----------------+-----------+------------------------------------------
value | integer | | not null | nextval('testtable_value_seq'::regclass)
Index :
"testtable_pkey" PRIMARY KEY, btree (value)
thibaut=# \ds testtable_value_seq
Liste des relations
Schéma | Nom | Type | Propriétaire
--------+---------------------+----------+--------------
public | testtable_value_seq | séquence | thibaut
(1 line) The script does not create some real identity columns as we can use since PostgreSQL version 10: thibaut=# CREATE TABLE testtable2 ( value int PRIMARY KEY GENERATED ALWAYS AS IDENTITY);
CREATE TABLE
thibaut=# \d testtable2
Table « public.testtable2 »
Colonne | Type | Collationnement | NULL-able | Par défaut
---------+---------+-----------------+-----------+------------------------------
value | integer | | not null | generated always as identity
Index :
"testtable2_pkey" PRIMARY KEY, btree (value)
thibaut=# \ds testtable2_*
Liste des relations
Schéma | Nom | Type | Propriétaire
--------+----------------------+----------+--------------
public | testtable2_value_seq | séquence | thibaut
(1 ligne) Maybe we should now use IDENTITY columns. |
I think you are right. Maybe default to IDENTITY and put an option flag of sorts to use sequences (in case of older Postgres versions). What do you think? |
Very good idea! Can you propose a PR with this evolution? Cordialement, |
There is now the #118 that should do the trick. If you are still using it, could you test it on your data? |
#150 merged |
Is there a reason that the script creates sequences instead of marking a column as SERIAL?
I'm not a Postgres expert but I think it might be easier to use Serial.
Please let me know if there is an option for that
The text was updated successfully, but these errors were encountered: