Skip to content

Commit 16f23cb

Browse files
NamespaceMetadata Partitioning Alignment (#486)
1 parent d3fd8cd commit 16f23cb

File tree

8 files changed

+68
-71
lines changed

8 files changed

+68
-71
lines changed

common/persistence/sql/sqlplugin/mysql/namespace.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,38 +33,38 @@ import (
3333

3434
const (
3535
createNamespaceQuery = `INSERT INTO
36-
namespaces (id, name, is_global, data, data_encoding, notification_version)
37-
VALUES(?, ?, ?, ?, ?, ?)`
36+
namespaces (partition_id, id, name, is_global, data, data_encoding, notification_version)
37+
VALUES(?, ?, ?, ?, ?, ?, ?)`
3838

3939
updateNamespaceQuery = `UPDATE namespaces
4040
SET name = ?, data = ?, data_encoding = ?, notification_version = ?
41-
WHERE shard_id=54321 AND id = ?`
41+
WHERE partition_id=54321 AND id = ?`
4242

4343
getNamespacePart = `SELECT id, name, is_global, data, data_encoding, notification_version FROM namespaces`
4444

45-
getNamespaceByIDQuery = getNamespacePart + ` WHERE shard_id=? AND id = ?`
46-
getNamespaceByNameQuery = getNamespacePart + ` WHERE shard_id=? AND name = ?`
45+
getNamespaceByIDQuery = getNamespacePart + ` WHERE partition_id=? AND id = ?`
46+
getNamespaceByNameQuery = getNamespacePart + ` WHERE partition_id=? AND name = ?`
4747

48-
listNamespacesQuery = getNamespacePart + ` WHERE shard_id=? ORDER BY id LIMIT ?`
49-
listNamespacesRangeQuery = getNamespacePart + ` WHERE shard_id=? AND id > ? ORDER BY id LIMIT ?`
48+
listNamespacesQuery = getNamespacePart + ` WHERE partition_id=? ORDER BY id LIMIT ?`
49+
listNamespacesRangeQuery = getNamespacePart + ` WHERE partition_id=? AND id > ? ORDER BY id LIMIT ?`
5050

51-
deleteNamespaceByIDQuery = `DELETE FROM namespaces WHERE shard_id=? AND id = ?`
52-
deleteNamespaceByNameQuery = `DELETE FROM namespaces WHERE shard_id=? AND name = ?`
51+
deleteNamespaceByIDQuery = `DELETE FROM namespaces WHERE partition_id=? AND id = ?`
52+
deleteNamespaceByNameQuery = `DELETE FROM namespaces WHERE partition_id=? AND name = ?`
5353

54-
getNamespaceMetadataQuery = `SELECT notification_version FROM namespace_metadata`
55-
lockNamespaceMetadataQuery = `SELECT notification_version FROM namespace_metadata FOR UPDATE`
56-
updateNamespaceMetadataQuery = `UPDATE namespace_metadata SET notification_version = ? WHERE notification_version = ?`
54+
getNamespaceMetadataQuery = `SELECT notification_version FROM namespace_metadata WHERE partition_id = 54321`
55+
lockNamespaceMetadataQuery = `SELECT notification_version FROM namespace_metadata WHERE partition_id = 54321 FOR UPDATE`
56+
updateNamespaceMetadataQuery = `UPDATE namespace_metadata SET notification_version = ? WHERE notification_version = ? AND partition_id = 54321`
5757
)
5858

5959
const (
60-
shardID = 54321
60+
partitionID = 54321
6161
)
6262

6363
var errMissingArgs = errors.New("missing one or more args for API")
6464

6565
// InsertIntoNamespace inserts a single row into namespaces table
6666
func (mdb *db) InsertIntoNamespace(row *sqlplugin.NamespaceRow) (sql.Result, error) {
67-
return mdb.conn.Exec(createNamespaceQuery, row.ID, row.Name, row.IsGlobal, row.Data, row.DataEncoding, row.NotificationVersion)
67+
return mdb.conn.Exec(createNamespaceQuery, partitionID, row.ID, row.Name, row.IsGlobal, row.Data, row.DataEncoding, row.NotificationVersion)
6868
}
6969

7070
// UpdateNamespace updates a single row in namespaces table
@@ -89,9 +89,9 @@ func (mdb *db) selectFromNamespace(filter *sqlplugin.NamespaceFilter) ([]sqlplug
8989
var row sqlplugin.NamespaceRow
9090
switch {
9191
case filter.ID != nil:
92-
err = mdb.conn.Get(&row, getNamespaceByIDQuery, shardID, *filter.ID)
92+
err = mdb.conn.Get(&row, getNamespaceByIDQuery, partitionID, *filter.ID)
9393
case filter.Name != nil:
94-
err = mdb.conn.Get(&row, getNamespaceByNameQuery, shardID, *filter.Name)
94+
err = mdb.conn.Get(&row, getNamespaceByNameQuery, partitionID, *filter.Name)
9595
}
9696
if err != nil {
9797
return nil, err
@@ -104,9 +104,9 @@ func (mdb *db) selectAllFromNamespace(filter *sqlplugin.NamespaceFilter) ([]sqlp
104104
var rows []sqlplugin.NamespaceRow
105105
switch {
106106
case filter.GreaterThanID != nil:
107-
err = mdb.conn.Select(&rows, listNamespacesRangeQuery, shardID, *filter.GreaterThanID, *filter.PageSize)
107+
err = mdb.conn.Select(&rows, listNamespacesRangeQuery, partitionID, *filter.GreaterThanID, *filter.PageSize)
108108
default:
109-
err = mdb.conn.Select(&rows, listNamespacesQuery, shardID, filter.PageSize)
109+
err = mdb.conn.Select(&rows, listNamespacesQuery, partitionID, filter.PageSize)
110110
}
111111
return rows, err
112112
}
@@ -117,9 +117,9 @@ func (mdb *db) DeleteFromNamespace(filter *sqlplugin.NamespaceFilter) (sql.Resul
117117
var result sql.Result
118118
switch {
119119
case filter.ID != nil:
120-
result, err = mdb.conn.Exec(deleteNamespaceByIDQuery, shardID, filter.ID)
120+
result, err = mdb.conn.Exec(deleteNamespaceByIDQuery, partitionID, filter.ID)
121121
default:
122-
result, err = mdb.conn.Exec(deleteNamespaceByNameQuery, shardID, filter.Name)
122+
result, err = mdb.conn.Exec(deleteNamespaceByNameQuery, partitionID, filter.Name)
123123
}
124124
return result, err
125125
}

common/persistence/sql/sqlplugin/postgres/namespace.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,38 +33,38 @@ import (
3333

3434
const (
3535
createNamespaceQuery = `INSERT INTO
36-
namespaces (id, name, is_global, data, data_encoding, notification_version)
37-
VALUES($1, $2, $3, $4, $5, $6)`
36+
namespaces (partition_id, id, name, is_global, data, data_encoding, notification_version)
37+
VALUES($1, $2, $3, $4, $5, $6, $7)`
3838

3939
updateNamespaceQuery = `UPDATE namespaces
4040
SET name = $1, data = $2, data_encoding = $3, notification_version = $4
41-
WHERE shard_id=54321 AND id = $5`
41+
WHERE partition_id=54321 AND id = $5`
4242

4343
getNamespacePart = `SELECT id, name, is_global, data, data_encoding, notification_version FROM namespaces`
4444

45-
getNamespaceByIDQuery = getNamespacePart + ` WHERE shard_id=$1 AND id = $2`
46-
getNamespaceByNameQuery = getNamespacePart + ` WHERE shard_id=$1 AND name = $2`
45+
getNamespaceByIDQuery = getNamespacePart + ` WHERE partition_id=$1 AND id = $2`
46+
getNamespaceByNameQuery = getNamespacePart + ` WHERE partition_id=$1 AND name = $2`
4747

48-
listNamespacesQuery = getNamespacePart + ` WHERE shard_id=$1 ORDER BY id LIMIT $2`
49-
listNamespacesRangeQuery = getNamespacePart + ` WHERE shard_id=$1 AND id > $2 ORDER BY id LIMIT $3`
48+
listNamespacesQuery = getNamespacePart + ` WHERE partition_id=$1 ORDER BY id LIMIT $2`
49+
listNamespacesRangeQuery = getNamespacePart + ` WHERE partition_id=$1 AND id > $2 ORDER BY id LIMIT $3`
5050

51-
deleteNamespaceByIDQuery = `DELETE FROM namespaces WHERE shard_id=$1 AND id = $2`
52-
deleteNamespaceByNameQuery = `DELETE FROM namespaces WHERE shard_id=$1 AND name = $2`
51+
deleteNamespaceByIDQuery = `DELETE FROM namespaces WHERE partition_id=$1 AND id = $2`
52+
deleteNamespaceByNameQuery = `DELETE FROM namespaces WHERE partition_id=$1 AND name = $2`
5353

54-
getNamespaceMetadataQuery = `SELECT notification_version FROM namespace_metadata`
55-
lockNamespaceMetadataQuery = `SELECT notification_version FROM namespace_metadata FOR UPDATE`
56-
updateNamespaceMetadataQuery = `UPDATE namespace_metadata SET notification_version = $1 WHERE notification_version = $2`
54+
getNamespaceMetadataQuery = `SELECT notification_version FROM namespace_metadata WHERE partition_id=$1`
55+
lockNamespaceMetadataQuery = `SELECT notification_version FROM namespace_metadata WHERE partition_id=$1 FOR UPDATE`
56+
updateNamespaceMetadataQuery = `UPDATE namespace_metadata SET notification_version = $1 WHERE notification_version = $2 AND partition_id=$3`
5757
)
5858

5959
const (
60-
shardID = 54321
60+
partitionID = 54321
6161
)
6262

6363
var errMissingArgs = errors.New("missing one or more args for API")
6464

6565
// InsertIntoNamespace inserts a single row into namespaces table
6666
func (pdb *db) InsertIntoNamespace(row *sqlplugin.NamespaceRow) (sql.Result, error) {
67-
return pdb.conn.Exec(createNamespaceQuery, row.ID, row.Name, row.IsGlobal, row.Data, row.DataEncoding, row.NotificationVersion)
67+
return pdb.conn.Exec(createNamespaceQuery, partitionID, row.ID, row.Name, row.IsGlobal, row.Data, row.DataEncoding, row.NotificationVersion)
6868
}
6969

7070
// UpdateNamespace updates a single row in namespaces table
@@ -89,9 +89,9 @@ func (pdb *db) selectFromNamespace(filter *sqlplugin.NamespaceFilter) ([]sqlplug
8989
var row sqlplugin.NamespaceRow
9090
switch {
9191
case filter.ID != nil:
92-
err = pdb.conn.Get(&row, getNamespaceByIDQuery, shardID, *filter.ID)
92+
err = pdb.conn.Get(&row, getNamespaceByIDQuery, partitionID, *filter.ID)
9393
case filter.Name != nil:
94-
err = pdb.conn.Get(&row, getNamespaceByNameQuery, shardID, *filter.Name)
94+
err = pdb.conn.Get(&row, getNamespaceByNameQuery, partitionID, *filter.Name)
9595
}
9696
if err != nil {
9797
return nil, err
@@ -104,9 +104,9 @@ func (pdb *db) selectAllFromNamespace(filter *sqlplugin.NamespaceFilter) ([]sqlp
104104
var rows []sqlplugin.NamespaceRow
105105
switch {
106106
case filter.GreaterThanID != nil:
107-
err = pdb.conn.Select(&rows, listNamespacesRangeQuery, shardID, *filter.GreaterThanID, *filter.PageSize)
107+
err = pdb.conn.Select(&rows, listNamespacesRangeQuery, partitionID, *filter.GreaterThanID, *filter.PageSize)
108108
default:
109-
err = pdb.conn.Select(&rows, listNamespacesQuery, shardID, filter.PageSize)
109+
err = pdb.conn.Select(&rows, listNamespacesQuery, partitionID, filter.PageSize)
110110
}
111111
return rows, err
112112
}
@@ -117,28 +117,28 @@ func (pdb *db) DeleteFromNamespace(filter *sqlplugin.NamespaceFilter) (sql.Resul
117117
var result sql.Result
118118
switch {
119119
case filter.ID != nil:
120-
result, err = pdb.conn.Exec(deleteNamespaceByIDQuery, shardID, filter.ID)
120+
result, err = pdb.conn.Exec(deleteNamespaceByIDQuery, partitionID, filter.ID)
121121
default:
122-
result, err = pdb.conn.Exec(deleteNamespaceByNameQuery, shardID, filter.Name)
122+
result, err = pdb.conn.Exec(deleteNamespaceByNameQuery, partitionID, filter.Name)
123123
}
124124
return result, err
125125
}
126126

127127
// LockNamespaceMetadata acquires a write lock on a single row in namespace_metadata table
128128
func (pdb *db) LockNamespaceMetadata() error {
129129
var row sqlplugin.NamespaceMetadataRow
130-
err := pdb.conn.Get(&row.NotificationVersion, lockNamespaceMetadataQuery)
130+
err := pdb.conn.Get(&row.NotificationVersion, lockNamespaceMetadataQuery, partitionID)
131131
return err
132132
}
133133

134134
// SelectFromNamespaceMetadata reads a single row in namespace_metadata table
135135
func (pdb *db) SelectFromNamespaceMetadata() (*sqlplugin.NamespaceMetadataRow, error) {
136136
var row sqlplugin.NamespaceMetadataRow
137-
err := pdb.conn.Get(&row.NotificationVersion, getNamespaceMetadataQuery)
137+
err := pdb.conn.Get(&row.NotificationVersion, getNamespaceMetadataQuery, partitionID)
138138
return &row, err
139139
}
140140

141141
// UpdateNamespaceMetadata updates a single row in namespace_metadata table
142142
func (pdb *db) UpdateNamespaceMetadata(row *sqlplugin.NamespaceMetadataRow) (sql.Result, error) {
143-
return pdb.conn.Exec(updateNamespaceMetadataQuery, row.NotificationVersion+1, row.NotificationVersion)
143+
return pdb.conn.Exec(updateNamespaceMetadataQuery, row.NotificationVersion+1, row.NotificationVersion, partitionID)
144144
}

go.mod

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ require (
1111
github.com/beorn7/perks v1.0.1 // indirect
1212
github.com/bitly/go-hostpool v0.1.0 // indirect
1313
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869
14-
github.com/bmizerany/perks v0.0.0-20141205001514-d9a9656a3a4b // indirect
1514
github.com/bsm/sarama-cluster v2.1.15+incompatible
1615
github.com/cactus/go-statsd-client/statsd v0.0.0-20200423205355-cb0885a1018c
1716
github.com/cch123/elasticsql v1.0.1
@@ -27,7 +26,6 @@ require (
2726
github.com/golang/mock v1.4.3
2827
github.com/golang/protobuf v1.4.2
2928
github.com/google/uuid v1.1.1
30-
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
3129
github.com/hashicorp/go-version v1.2.0
3230
github.com/iancoleman/strcase v0.0.0-20191112232945-16388991a334
3331
github.com/jcmturner/gokrb5/v8 v8.3.0 // indirect
@@ -48,14 +46,12 @@ require (
4846
github.com/olivere/elastic v6.2.32+incompatible
4947
github.com/onsi/ginkgo v1.10.3 // indirect
5048
github.com/onsi/gomega v1.7.1 // indirect
51-
github.com/opentracing/opentracing-go v1.2.0
49+
github.com/opentracing/opentracing-go v1.2.0 // indirect
5250
github.com/pborman/uuid v1.2.0
5351
github.com/pierrec/lz4 v2.5.2+incompatible // indirect
54-
github.com/prashantv/protectmem v0.0.0-20171002184600-e20412882b3a // indirect
5552
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect
5653
github.com/robfig/cron v1.2.0
5754
github.com/sirupsen/logrus v1.6.0
58-
github.com/streadway/quantile v0.0.0-20150917103942-b0c588724d25 // indirect
5955
github.com/stretchr/testify v1.6.1
6056
github.com/temporalio/ringpop-go v0.0.0-20200708034907-1e016ebb537a
6157
github.com/uber-common/bark v1.3.0 // indirect
@@ -76,7 +72,6 @@ require (
7672
google.golang.org/api v0.26.0
7773
google.golang.org/grpc v1.30.0
7874
google.golang.org/grpc/examples v0.0.0-20200625174016-7a808837ae92
79-
gopkg.in/inf.v0 v0.9.1 // indirect
8075
gopkg.in/validator.v2 v2.0.0-20200605151824-2b28d334fa05
8176
gopkg.in/yaml.v2 v2.3.0
8277
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect

go.sum

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ github.com/bmizerany/perks v0.0.0-20141205001514-d9a9656a3a4b h1:AP/Y7sqYicnjGDf
6464
github.com/bmizerany/perks v0.0.0-20141205001514-d9a9656a3a4b/go.mod h1:ac9efd0D1fsDb3EJvhqgXRbFx7bs2wqZ10HQPeU8U/Q=
6565
github.com/bsm/sarama-cluster v2.1.15+incompatible h1:RkV6WiNRnqEEbp81druK8zYhmnIgdOjqSVi0+9Cnl2A=
6666
github.com/bsm/sarama-cluster v2.1.15+incompatible/go.mod h1:r7ao+4tTNXvWm+VRpRJchr2kQhqxgmAp2iEX5W96gMM=
67-
github.com/cactus/go-statsd-client v3.1.0+incompatible h1:jtloShmaP/MkAW68aaWwQZrzlOUXVLudFmBQsskTs7A=
68-
github.com/cactus/go-statsd-client v3.1.0+incompatible/go.mod h1:cMRcwZDklk7hXp+Law83urTHUiHMzCev/r4JMYr/zU0=
6967
github.com/cactus/go-statsd-client/statsd v0.0.0-20191106001114-12b4e2b38748 h1:bXxS5/Z3/dfc8iFniQfgogNBomo0u+1//9eP+jl8GVo=
7068
github.com/cactus/go-statsd-client/statsd v0.0.0-20191106001114-12b4e2b38748/go.mod h1:l/bIBLeOl9eX+wxJAzxS4TveKRtAqlyDpHjhkfO0MEI=
7169
github.com/cactus/go-statsd-client/statsd v0.0.0-20200423205355-cb0885a1018c h1:HIGF0r/56+7fuIZw2V4isE22MK6xpxWx7BbV8dJ290w=
@@ -119,8 +117,6 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2
119117
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
120118
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
121119
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
122-
github.com/gocql/gocql v0.0.0-20171220143535-56a164ee9f31 h1:kPjRO/S+4pjIgvub1+xsaQ6xudIgvVPoJYGGkJ7Qx8E=
123-
github.com/gocql/gocql v0.0.0-20171220143535-56a164ee9f31/go.mod h1:GjP0ITc4WbMO5dEWwikPqq0ZWbloAO6CO6g0VAK7tTc=
124120
github.com/gocql/gocql v0.0.0-20200624222514-34081eda590e h1:SroDcndcOU9BVAduPf/PXihXoR2ZYTQYLXbupbqxAyQ=
125121
github.com/gocql/gocql v0.0.0-20200624222514-34081eda590e/go.mod h1:DL0ekTmBSTdlNF25Orwt/JMzqIq3EJ4MVa/J/uK64OY=
126122
github.com/gogo/googleapis v0.0.0-20180223154316-0cd9801be74a/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
@@ -325,8 +321,6 @@ github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H
325321
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
326322
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
327323
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
328-
github.com/temporalio/ringpop-go v0.0.0-20200706180029-8936e3cea8e8 h1:pu3TqFGYSogjplEdUq1lI7kteZujCNSkTuvrJl+blUU=
329-
github.com/temporalio/ringpop-go v0.0.0-20200706180029-8936e3cea8e8/go.mod h1:6THFNVUdhnG5dRaorImAh0F/7dJLaInhLremkcVo/7U=
330324
github.com/temporalio/ringpop-go v0.0.0-20200708034907-1e016ebb537a h1:yyEBPFtXeNbtqFitJ+X3L7wpI9MrKrl8zSH3M29pREo=
331325
github.com/temporalio/ringpop-go v0.0.0-20200708034907-1e016ebb537a/go.mod h1:Ek9J8CAfI1IwVSqHpTOgj7FjzRSJ5SM/ud52eCmkhsw=
332326
github.com/uber-common/bark v1.0.0/go.mod h1:g0ZuPcD7XiExKHynr93Q742G/sbrdVQkghrqLGOoFuY=

schema/mysql/v57/temporal/schema.sql

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
CREATE TABLE namespaces(
2-
shard_id INT NOT NULL DEFAULT 54321,
2+
partition_id INT NOT NULL,
33
id BINARY(16) NOT NULL,
44
name VARCHAR(255) UNIQUE NOT NULL,
55
notification_version BIGINT NOT NULL,
66
--
77
data BLOB NOT NULL,
88
data_encoding VARCHAR(16) NOT NULL,
99
is_global TINYINT(1) NOT NULL,
10-
PRIMARY KEY(shard_id, id)
10+
PRIMARY KEY(partition_id, id)
1111
);
1212

1313
CREATE TABLE namespace_metadata (
14-
notification_version BIGINT NOT NULL
14+
partition_id INT NOT NULL,
15+
notification_version BIGINT NOT NULL,
16+
PRIMARY KEY(partition_id)
1517
);
1618

17-
INSERT INTO namespace_metadata (notification_version) VALUES (1);
19+
INSERT INTO namespace_metadata (partition_id, notification_version) VALUES (54321, 1);
1820

1921
CREATE TABLE shards (
2022
shard_id INT NOT NULL,

schema/mysql/v57/temporal/versioned/v1.0/schema.sql

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
CREATE TABLE namespaces(
2-
shard_id INT NOT NULL DEFAULT 54321,
2+
partition_id INT NOT NULL,
33
id BINARY(16) NOT NULL,
44
name VARCHAR(255) UNIQUE NOT NULL,
55
notification_version BIGINT NOT NULL,
66
--
77
data BLOB NOT NULL,
88
data_encoding VARCHAR(16) NOT NULL,
99
is_global TINYINT(1) NOT NULL,
10-
PRIMARY KEY(shard_id, id)
10+
PRIMARY KEY(partition_id, id)
1111
);
1212

1313
CREATE TABLE namespace_metadata (
14-
notification_version BIGINT NOT NULL
14+
partition_id INT NOT NULL,
15+
notification_version BIGINT NOT NULL,
16+
PRIMARY KEY(partition_id)
1517
);
1618

17-
INSERT INTO namespace_metadata (notification_version) VALUES (1);
19+
INSERT INTO namespace_metadata (partition_id, notification_version) VALUES (54321, 1);
1820

1921
CREATE TABLE shards (
2022
shard_id INT NOT NULL,

schema/postgres/temporal/schema.sql

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
CREATE TABLE namespaces(
2-
shard_id INTEGER NOT NULL DEFAULT 54321,
2+
partition_id INTEGER NOT NULL,
33
id BYTEA NOT NULL,
44
name VARCHAR(255) UNIQUE NOT NULL,
55
notification_version BIGINT NOT NULL,
66
--
77
data BYTEA NOT NULL,
88
data_encoding VARCHAR(16) NOT NULL,
99
is_global BOOLEAN NOT NULL,
10-
PRIMARY KEY(shard_id, id)
10+
PRIMARY KEY(partition_id, id)
1111
);
1212

1313
CREATE TABLE namespace_metadata (
14-
notification_version BIGINT NOT NULL
14+
partition_id INTEGER NOT NULL,
15+
notification_version BIGINT NOT NULL,
16+
PRIMARY KEY(partition_id)
1517
);
1618

17-
INSERT INTO namespace_metadata (notification_version) VALUES (1);
19+
INSERT INTO namespace_metadata (partition_id, notification_version) VALUES (54321, 1);
1820

1921
CREATE TABLE shards (
2022
shard_id INTEGER NOT NULL,

schema/postgres/temporal/versioned/v1.0/schema.sql

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
CREATE TABLE namespaces(
2-
shard_id INTEGER NOT NULL DEFAULT 54321,
2+
partition_id INTEGER NOT NULL,
33
id BYTEA NOT NULL,
44
name VARCHAR(255) UNIQUE NOT NULL,
55
notification_version BIGINT NOT NULL,
66
--
77
data BYTEA NOT NULL,
88
data_encoding VARCHAR(16) NOT NULL,
99
is_global BOOLEAN NOT NULL,
10-
PRIMARY KEY(shard_id, id)
10+
PRIMARY KEY(partition_id, id)
1111
);
1212

1313
CREATE TABLE namespace_metadata (
14-
notification_version BIGINT NOT NULL
14+
partition_id INTEGER NOT NULL,
15+
notification_version BIGINT NOT NULL,
16+
PRIMARY KEY(partition_id)
1517
);
1618

17-
INSERT INTO namespace_metadata (notification_version) VALUES (1);
19+
INSERT INTO namespace_metadata (partition_id, notification_version) VALUES (54321, 1);
1820

1921
CREATE TABLE shards (
2022
shard_id INTEGER NOT NULL,

0 commit comments

Comments
 (0)