Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a6d0448

Browse files
committed
chore: pluralize table names
1 parent 810b2d2 commit a6d0448

9 files changed

+48
-24
lines changed

coderd/coderd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ type Options struct {
2727

2828
// New constructs the Coder API into an HTTP handler.
2929
//
30-
// A wait function is returned to handle awaiting closure
31-
// of hijacked HTTP requests.
30+
// A wait function is returned to handle awaiting closure of hijacked HTTP
31+
// requests.
3232
func New(options *Options) (http.Handler, func()) {
3333
api := &api{
3434
Options: options,
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
DROP TABLE files;
2+
DROP TYPE provisioner_type;
3+
DROP TABLE projects;
4+
DROP TABLE project_versions;

database/migrations/000002_projects.up.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Store arbitrary data like project source code or avatars.
2-
CREATE TABLE file (
2+
CREATE TABLE files (
33
hash varchar(64) NOT NULL UNIQUE,
44
created_at timestamptz NOT NULL,
55
created_by text NOT NULL,
@@ -11,7 +11,7 @@ CREATE TYPE provisioner_type AS ENUM ('echo', 'terraform');
1111

1212
-- Project defines infrastructure that your software project
1313
-- requires for development.
14-
CREATE TABLE project (
14+
CREATE TABLE projects (
1515
id uuid NOT NULL UNIQUE,
1616
created_at timestamptz NOT NULL,
1717
updated_at timestamptz NOT NULL,
@@ -30,10 +30,10 @@ CREATE TABLE project (
3030
-- Project Versions store historical project data. When a Project Version is imported,
3131
-- an "import" job is queued to parse parameters. A Project Version
3232
-- can only be used if the import job succeeds.
33-
CREATE TABLE project_version (
33+
CREATE TABLE project_versions (
3434
id uuid NOT NULL UNIQUE,
3535
-- This should be indexed.
36-
project_id uuid REFERENCES project (id),
36+
project_id uuid REFERENCES projects (id),
3737
organization_id text NOT NULL,
3838
created_at timestamptz NOT NULL,
3939
updated_at timestamptz NOT NULL,
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DROP TABLE workspaces
2+
DROP TYPE workspace_transition;

database/migrations/000003_workspaces.up.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
CREATE TABLE workspace (
1+
CREATE TABLE workspaces (
22
id uuid NOT NULL UNIQUE,
33
created_at timestamptz NOT NULL,
44
updated_at timestamptz NOT NULL,
55
owner_id text NOT NULL,
6-
project_id uuid NOT NULL REFERENCES project (id),
6+
project_id uuid NOT NULL REFERENCES projects (id),
77
name varchar(64) NOT NULL,
88
UNIQUE(owner_id, name)
99
);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
DROP TABLE provisioner_daemons;
2+
DROP TYPE provisioner_job_type;
3+
DROP TYPE provisioner_storage_method;
4+
DROP TABLE provisioner_jobs;
5+
DROP TYPE log_level;
6+
DROP TYPE log_source;
7+
DROP TABLE provisioner_job_logs;
8+
DROP TABLE workspace_resources;
9+
DROP TABLE workspace_agents;
10+
DROP TYPE parameter_scope;
11+
DROP TYPE parameter_type_system;
12+
DROP TYPE parameter_destination_scheme;
13+
DROP TABLE parameter_schemas;
14+
DROP TABLE parameter_values;
15+
DROP TABLE workspace_builds;

database/migrations/000004_jobs.up.sql

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CREATE TABLE IF NOT EXISTS provisioner_daemon (
1+
CREATE TABLE IF NOT EXISTS provisioner_daemons (
22
id uuid NOT NULL UNIQUE,
33
created_at timestamptz NOT NULL,
44
updated_at timestamptz,
@@ -16,7 +16,7 @@ CREATE TYPE provisioner_job_type AS ENUM (
1616

1717
CREATE TYPE provisioner_storage_method AS ENUM ('file');
1818

19-
CREATE TABLE IF NOT EXISTS provisioner_job (
19+
CREATE TABLE IF NOT EXISTS provisioner_jobs (
2020
id uuid NOT NULL UNIQUE,
2121
created_at timestamptz NOT NULL,
2222
updated_at timestamptz NOT NULL,
@@ -47,7 +47,7 @@ CREATE TYPE log_source AS ENUM (
4747
'provisioner'
4848
);
4949

50-
CREATE TABLE IF NOT EXISTS provisioner_job_log (
50+
CREATE TABLE IF NOT EXISTS provisioner_job_logs (
5151
id uuid NOT NULL UNIQUE,
5252
job_id uuid NOT NULL REFERENCES provisioner_job (id) ON DELETE CASCADE,
5353
created_at timestamptz NOT NULL,
@@ -56,7 +56,7 @@ CREATE TABLE IF NOT EXISTS provisioner_job_log (
5656
output varchar(1024) NOT NULL
5757
);
5858

59-
CREATE TABLE workspace_resource (
59+
CREATE TABLE workspace_resources (
6060
id uuid NOT NULL UNIQUE,
6161
created_at timestamptz NOT NULL,
6262
job_id uuid NOT NULL REFERENCES provisioner_job(id) ON DELETE CASCADE,
@@ -66,7 +66,7 @@ CREATE TABLE workspace_resource (
6666
agent_id uuid
6767
);
6868

69-
CREATE TABLE workspace_agent (
69+
CREATE TABLE workspace_agents (
7070
id uuid NOT NULL UNIQUE,
7171
created_at timestamptz NOT NULL,
7272
updated_at timestamptz,
@@ -105,10 +105,10 @@ CREATE TYPE parameter_destination_scheme AS ENUM('none', 'environment_variable',
105105
-- Parameter types, description, and validation will produce
106106
-- a UI for users to enter values.
107107
-- Needs to be made consistent with the examples below.
108-
CREATE TABLE parameter_schema (
108+
CREATE TABLE parameter_schemas (
109109
id uuid NOT NULL UNIQUE,
110110
created_at timestamptz NOT NULL,
111-
job_id uuid NOT NULL REFERENCES provisioner_job(id) ON DELETE CASCADE,
111+
job_id uuid NOT NULL REFERENCES provisioner_jobs (id) ON DELETE CASCADE,
112112
name varchar(64) NOT NULL,
113113
description varchar(8192) NOT NULL DEFAULT '',
114114
default_source_scheme parameter_source_scheme,
@@ -130,7 +130,7 @@ CREATE TABLE parameter_schema (
130130
);
131131

132132
-- Parameters are provided to jobs for provisioning and to workspaces.
133-
CREATE TABLE parameter_value (
133+
CREATE TABLE parameter_values (
134134
id uuid NOT NULL UNIQUE,
135135
created_at timestamptz NOT NULL,
136136
updated_at timestamptz NOT NULL,
@@ -144,12 +144,12 @@ CREATE TABLE parameter_value (
144144
UNIQUE(scope_id, name)
145145
);
146146

147-
CREATE TABLE workspace_build (
147+
CREATE TABLE workspace_builds (
148148
id uuid NOT NULL UNIQUE,
149149
created_at timestamptz NOT NULL,
150150
updated_at timestamptz NOT NULL,
151-
workspace_id uuid NOT NULL REFERENCES workspace (id) ON DELETE CASCADE,
152-
project_version_id uuid NOT NULL REFERENCES project_version (id) ON DELETE CASCADE,
151+
workspace_id uuid NOT NULL REFERENCES workspaces (id) ON DELETE CASCADE,
152+
project_version_id uuid NOT NULL REFERENCES project_versions (id) ON DELETE CASCADE,
153153
name varchar(64) NOT NULL,
154154
before_id uuid,
155155
after_id uuid,
@@ -158,6 +158,6 @@ CREATE TABLE workspace_build (
158158
-- State stored by the provisioner
159159
provisioner_state bytea,
160160
-- Job ID of the action
161-
job_id uuid NOT NULL UNIQUE REFERENCES provisioner_job(id) ON DELETE CASCADE,
161+
job_id uuid NOT NULL UNIQUE REFERENCES provisioner_jobs (id) ON DELETE CASCADE,
162162
UNIQUE(workspace_id, name)
163-
);
163+
);
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
25
cd "$(dirname "$0")"
36

47
if [ -z "$1" ]; then
58
echo "First argument is the migration name!"
69
exit 1
710
fi
811

9-
migrate create -ext sql -dir . -seq $1
12+
migrate create -ext sql -dir . -seq "$1"
1013

1114
echo "Run \"make gen\" to generate models."

httpmw/httpmw.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ func parseUUID(rw http.ResponseWriter, r *http.Request, param string) (uuid.UUID
1515
rawID := chi.URLParam(r, param)
1616
if rawID == "" {
1717
httpapi.Write(rw, http.StatusBadRequest, httpapi.Response{
18-
Message: fmt.Sprintf("%s must be provided", param),
18+
Message: fmt.Sprintf("%q must be provided", param),
1919
})
2020
return uuid.UUID{}, false
2121
}
2222
parsed, err := uuid.Parse(rawID)
2323
if err != nil {
2424
httpapi.Write(rw, http.StatusBadRequest, httpapi.Response{
25-
Message: fmt.Sprintf("%s must be a uuid", param),
25+
Message: fmt.Sprintf("%q must be a uuid", param),
2626
})
2727
return uuid.UUID{}, false
2828
}

0 commit comments

Comments
 (0)