Add support for Yugabyte DB
This commit is contained in:
parent
c85d379fe2
commit
12007db76e
|
@ -11,7 +11,7 @@ for (i = 0; i < user_count; i++) {
|
||||||
var pwd = fake.password()
|
var pwd = fake.password()
|
||||||
var data = {
|
var data = {
|
||||||
full_name: fake.name(),
|
full_name: fake.name(),
|
||||||
avatar: fake.image_url(),
|
avatar: fake.avatar_url(200),
|
||||||
phone: fake.phone(),
|
phone: fake.phone(),
|
||||||
email: fake.email(),
|
email: fake.email(),
|
||||||
password: pwd,
|
password: pwd,
|
||||||
|
|
|
@ -257,7 +257,7 @@ func (m *Migrator) MigrateTo(targetVersion int32) (err error) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
// Lock to ensure multiple migrations cannot occur simultaneously
|
// Lock to ensure multiple migrations cannot occur simultaneously
|
||||||
lockNum := int64(9628173550095224) // arbitrary random number
|
lockNum := int64(9628173550095224) // arbitrary random number
|
||||||
if _, lockErr := m.conn.Exec(ctx, "select pg_advisory_lock($1)", lockNum); lockErr != nil {
|
if _, lockErr := m.conn.Exec(ctx, "select pg_try_advisory_lock($1)", lockNum); lockErr != nil {
|
||||||
return lockErr
|
return lockErr
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -331,9 +331,9 @@ func (m *Migrator) MigrateTo(targetVersion int32) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset all database connection settings. Important to do before updating version as search_path may have been changed.
|
// Reset all database connection settings. Important to do before updating version as search_path may have been changed.
|
||||||
if _, err := tx.Exec(ctx, "reset all"); err != nil {
|
// if _, err := tx.Exec(ctx, "reset all"); err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Add one to the version
|
// Add one to the version
|
||||||
_, err = tx.Exec(ctx, "update "+m.versionTable+" set version=$1", sequence)
|
_, err = tx.Exec(ctx, "update "+m.versionTable+" set version=$1", sequence)
|
||||||
|
|
|
@ -167,7 +167,7 @@ SELECT
|
||||||
ELSE ''::text
|
ELSE ''::text
|
||||||
END AS foreignkey,
|
END AS foreignkey,
|
||||||
CASE
|
CASE
|
||||||
WHEN p.contype = ('f'::char) THEN p.confkey
|
WHEN p.contype = ('f'::char) THEN p.confkey::int2[]
|
||||||
ELSE ARRAY[]::int2[]
|
ELSE ARRAY[]::int2[]
|
||||||
END AS foreignkey_fieldnum
|
END AS foreignkey_fieldnum
|
||||||
FROM pg_attribute f
|
FROM pg_attribute f
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
|
@ -145,6 +146,17 @@ func logFunc(args ...interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func avatarURL(size int) string {
|
||||||
|
if size == 0 {
|
||||||
|
size = 200
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("https://i.pravatar.cc/%d?%d", size, rand.Intn(5000))
|
||||||
|
}
|
||||||
|
|
||||||
|
func imageURL(width int, height int) string {
|
||||||
|
return fmt.Sprintf("https://picsum.photos/%d/%d?%d", width, height, rand.Intn(5000))
|
||||||
|
}
|
||||||
|
|
||||||
//nolint: errcheck
|
//nolint: errcheck
|
||||||
func setFakeFuncs(f *goja.Object) {
|
func setFakeFuncs(f *goja.Object) {
|
||||||
gofakeit.Seed(0)
|
gofakeit.Seed(0)
|
||||||
|
@ -222,7 +234,8 @@ func setFakeFuncs(f *goja.Object) {
|
||||||
|
|
||||||
// Internet
|
// Internet
|
||||||
f.Set("url", gofakeit.URL)
|
f.Set("url", gofakeit.URL)
|
||||||
f.Set("image_url", gofakeit.ImageURL)
|
f.Set("image_url", imageURL)
|
||||||
|
f.Set("avatar_url", avatarURL)
|
||||||
f.Set("domain_name", gofakeit.DomainName)
|
f.Set("domain_name", gofakeit.DomainName)
|
||||||
f.Set("domain_suffix", gofakeit.DomainSuffix)
|
f.Set("domain_suffix", gofakeit.DomainSuffix)
|
||||||
f.Set("ipv4_address", gofakeit.IPv4Address)
|
f.Set("ipv4_address", gofakeit.IPv4Address)
|
||||||
|
|
|
@ -1,14 +1,53 @@
|
||||||
version: '3.4'
|
version: '3.4'
|
||||||
services:
|
services:
|
||||||
|
# Postgres DB
|
||||||
db:
|
db:
|
||||||
image: postgres
|
image: postgres:latest
|
||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
- "5432:5432"
|
||||||
|
|
||||||
|
# Yugabyte DB
|
||||||
|
# yb-master:
|
||||||
|
# image: yugabytedb/yugabyte:latest
|
||||||
|
# container_name: yb-master-n1
|
||||||
|
# command: [ "/home/yugabyte/bin/yb-master",
|
||||||
|
# "--fs_data_dirs=/mnt/disk0,/mnt/disk1",
|
||||||
|
# "--master_addresses=yb-master-n1:7100",
|
||||||
|
# "--replication_factor=1",
|
||||||
|
# "--enable_ysql=true"]
|
||||||
|
# ports:
|
||||||
|
# - "7000:7000"
|
||||||
|
# environment:
|
||||||
|
# SERVICE_7000_NAME: yb-master
|
||||||
|
|
||||||
|
# db:
|
||||||
|
# image: yugabytedb/yugabyte:latest
|
||||||
|
# container_name: yb-tserver-n1
|
||||||
|
# command: [ "/home/yugabyte/bin/yb-tserver",
|
||||||
|
# "--fs_data_dirs=/mnt/disk0,/mnt/disk1",
|
||||||
|
# "--start_pgsql_proxy",
|
||||||
|
# "--tserver_master_addrs=yb-master-n1:7100"]
|
||||||
|
# ports:
|
||||||
|
# - "9042:9042"
|
||||||
|
# - "6379:6379"
|
||||||
|
# - "5433:5433"
|
||||||
|
# - "9000:9000"
|
||||||
|
# environment:
|
||||||
|
# SERVICE_5433_NAME: ysql
|
||||||
|
# SERVICE_9042_NAME: ycql
|
||||||
|
# SERVICE_6379_NAME: yedis
|
||||||
|
# SERVICE_9000_NAME: yb-tserver
|
||||||
|
# depends_on:
|
||||||
|
# - yb-master
|
||||||
|
|
||||||
{% app_name_slug %}_api:
|
{% app_name_slug %}_api:
|
||||||
image: dosco/super-graph:latest
|
image: dosco/super-graph:latest
|
||||||
environment:
|
environment:
|
||||||
GO_ENV: "development"
|
GO_ENV: "development"
|
||||||
|
# Uncomment below for Yugabyte DB
|
||||||
|
# SG_DATABASE_PORT: 5433
|
||||||
|
# SG_DATABASE_USER: yugabyte
|
||||||
|
# SG_DATABASE_PASSWORD: yugabyte
|
||||||
volumes:
|
volumes:
|
||||||
- ./config:/config
|
- ./config:/config
|
||||||
ports:
|
ports:
|
||||||
|
|
Loading…
Reference in New Issue