Skip to content
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

chore(docker): Add vschema.json to Vitess with foreignKeyMode=managed #21879

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions commands.txt
Original file line number Diff line number Diff line change
@@ -0,0 1,26 @@
mysql -h 127.0.0.1 -P 33807 -u root -p

SHOW DATABASES;

CREATE DATABASE foo;

USE foo;

SHOW TABLES;

CREATE TABLE Persons (
PersonID int NOT NULL,
FirstName varchar(50) NOT NULL,
LastName varchar(50) NOT NULL,
PRIMARY KEY (PersonID)
);

CREATE TABLE Orders (
OrderID int NOT NULL,
OrderNumber int NOT NULL,
PersonID int,
PRIMARY KEY (OrderID),
FOREIGN KEY (PersonID) REFERENCES Persons(PersonID)
);

SHOW VSCHEMA KEYSPACES;
17 changes: 10 additions & 7 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,26 72,29 @@ services:
timeout: 2s
retries: 20

# Planetscale
# From https://github.com/prisma/prisma-engines/blob/976a00ae3c30ab9507fa742986c9c6f5327ba10f/docker-compose.yml
# Vitess (~Planetscale)
# https://vitess.io/docs/18.0/get-started/vttestserver-docker-image/
# mysql -h localhost -P 33807 --protocol=TCP -u root -p
vitess-8:
image: vitess/vttestserver:mysql80@sha256:1381e4cbbd390e5ac0edc1e67236fe49bd69cefd68f3e9b865c8883f57986587
image: janprisma/vttestserver:mysql80@sha256:bc3978c2ec58f0ded93280f79f00d99741a60e728a14989b473b75fb6d8282b8
restart: unless-stopped
ports:
- 33807:33807
environment:
PORT: '33804' # unused in testing, but required by vttestserver
KEYSPACES: 'unsharded' # unused in testing, but required by vttestserver
NUM_SHARDS: '1' # unused in testing, but required by vttestserver
PORT: '33804' # defines that accessible port will be 33807 (33804 3)
KEYSPACES: 'disallow,managed,unmanaged' # unused in testing, but required by vttestserver
NUM_SHARDS: '1,1,1' # unused in testing, but required by vttestserver
MYSQL_BIND_HOST: '0.0.0.0'
FOREIGN_KEY_MODE: 'disallow'
# FOREIGN_KEY_MODE: 'disallow'
MYSQL_MAX_CONNECTIONS: 100000
TABLET_REFRESH_INTERVAL: '1s'
healthcheck:
test: ['CMD', 'mysqladmin', 'ping', '-h127.0.0.1', '-P33807']
interval: 5s
timeout: 2s
retries: 20
volumes:
- ./vitess-config:/vt/schema

mysql:
image: mysql:8.0
Expand Down
4 changes: 4 additions & 0 deletions docker/vitess-config/disallow/vschema.json
Original file line number Diff line number Diff line change
@@ -0,0 1,4 @@
{
"sharded": false,
"foreignKeyMode": "disallow"
}
4 changes: 4 additions & 0 deletions docker/vitess-config/managed/vschema.json
Original file line number Diff line number Diff line change
@@ -0,0 1,4 @@
{
"sharded": false,
"foreignKeyMode": "managed"
}
4 changes: 4 additions & 0 deletions docker/vitess-config/unmanaged/vschema.json
Original file line number Diff line number Diff line change
@@ -0,0 1,4 @@
{
"sharded": false,
"foreignKeyMode": "unmanaged"
}
Loading