deep-foundation / deep-foundation/deeplinks

Do we really need manual sequence creation?

Open
#14 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
13
Forks
8
PR merge metrics
No merged PRs in 30d

Description

https://github.com/deepcase/deeplinks/blob/94d5926fdfaa0003c4a9c28980840d66512fdc4f/migrations/1616701513782-links.ts#L19-L23

Maybe we can just use the sorter version that makes the same thing using `id BIGSERIAL PRIMARY KEY`?
Or maybe it does not do the same thing?

```SQL
CREATE TABLE ${SCHEMA}."${TABLE_NAME}" (id BIGSERIAL PRIMARY KEY, from_id bigint DEFAULT 0, to_id bigint DEFAULT 0, type_id bigint NOT NULL);
```

I just tested this SQL statement:
```
CREATE TABLE test_table (
id BIGSERIAL PRIMARY KEY
);
```

And got this result:
![Screenshot_20210916_215335](https://user-images.githubusercontent.com/1431904/133668993-a56b2eda-5cbe-4361-acde-c4526f31795d.png)

As far as I can find in https://www.postgresql.org/docs/current/sql-createsequence.html
```sql
CREATE SEQUENCE ${TABLE_NAME}_id_seq
AS bigint
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
```
all these settings are default, so this is an equivalent of:
```sql
CREATE SEQUENCE ${TABLE_NAME}_id_seq;
```

And all the above is __exact__ equivalent of just `id BIGSERIAL PRIMARY KEY`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.