Skip to content

Commit 8828b0b

Browse files
mtangoosamdark
authored andcommitted
Add table schema for PostgreSQL to docs (yiisoft#348) [skip ci]
1 parent ee28f57 commit 8828b0b

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

docs/guide/driver-db.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ return [
3333
];
3434
```
3535

36-
You have to add a table to the database. Example schema for MySQL:
36+
You have to add a table to the database. Example schema for:
37+
38+
MySQL:
3739

3840
```SQL
3941
CREATE TABLE `queue` (
@@ -53,8 +55,33 @@ CREATE TABLE `queue` (
5355
KEY `priority` (`priority`)
5456
) ENGINE=InnoDB
5557
```
58+
and Postgresql
59+
60+
```SQL
61+
-- Necessary for creating Autoincrement field
62+
CREATE SEQUENCE queue_seq;
63+
64+
CREATE TABLE queue (
65+
id bigint NOT NULL DEFAULT NEXTVAL ('queue_seq'),
66+
channel varchar(255) NOT NULL,
67+
job bytea NOT NULL,
68+
pushed_at bigint NOT NULL,
69+
ttr bigint NOT NULL,
70+
delay bigint NOT NULL DEFAULT 0,
71+
priority bigint check (priority > 0) NOT NULL DEFAULT 1024,
72+
reserved_at bigint ,
73+
attempt bigint,
74+
done_at bigint,
75+
PRIMARY KEY (id)
76+
);
77+
-- Optional but good for speeding up queries
78+
CREATE INDEX channel ON queue (channel);
79+
CREATE INDEX reserved_at ON queue (reserved_at);
80+
CREATE INDEX priority ON queue (priority);
81+
```
82+
5683

57-
Migrations are available from [src/drivers/db/migrations](../../src/drivers/db/migrations).
84+
You can use migrations which are available from [src/drivers/db/migrations](../../src/drivers/db/migrations).
5885

5986
To add migrations to your application, edit the console config file to configure
6087
[a namespaced migration](http://www.yiiframework.com/doc-2.0/guide-db-migrations.html#namespaced-migrations):

0 commit comments

Comments
 (0)