Skip to content

Commit

Permalink
Send scheme when updating or creating database config
Browse files Browse the repository at this point in the history
  • Loading branch information
OilyLime committed Sep 14, 2023
1 parent 2f4a80b commit e3a4e79
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/wrangler/src/hyperdrive/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type Origin = {
};

export type PublicOrigin = Origin & {
scheme?: string;
database?: string;
user?: string;
};
Expand Down
7 changes: 6 additions & 1 deletion packages/wrangler/src/hyperdrive/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ export async function handler(

if (url.protocol === "") {
logger.log("You must specify the database protocol - e.g. 'postgresql:'.");
} else if (url.protocol !== "postgresql:" && url.protocol !== "") {
} else if (
url.protocol !== "postgresql:" &&
url.protocol !== "postgres:" &&
url.protocol !== ""
) {
logger.log(
"Only PostgreSQL or PostgreSQL compatible databases are currently supported."
);
Expand Down Expand Up @@ -65,6 +69,7 @@ export async function handler(
origin: {
host: url.hostname,
port: parseInt(url.port),
scheme: url.protocol,
database: url.pathname.replace("/", ""),
user: url.username,
password: url.password,
Expand Down
15 changes: 13 additions & 2 deletions packages/wrangler/src/hyperdrive/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,28 @@ export function options(yargs: CommonYargsArgv) {
.options({
"origin-host": {
type: "string",
describe: "",
describe: "The host of the origin database",
},
"origin-port": {
type: "number",
describe: "",
describe: "The port number of the origin database",
},
"origin-scheme": {
type: "string",
describe:
"The scheme used to connect to the origin database - e.g. postgresql or postgres",
},
database: {
type: "string",
describe: "The name of the database within the origin database",
},
"origin-user": {
type: "string",
describe: "The username used to connect to the origin database",
},
"origin-password": {
type: "string",
describe: "The password used to connect to the origin database",
},
})
.epilogue(hyperdriveBetaWarning);
Expand All @@ -53,6 +61,9 @@ export async function handler(
if (args.originPort) {
database.origin.port = args.originPort;
}
if (args.originScheme) {
database.origin.scheme = args.originScheme;
}
if (args.database) {
database.origin.database = args.database;
}
Expand Down

0 comments on commit e3a4e79

Please sign in to comment.