Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

add migrate script in root & --skip-confirmation

Roman Pominov0979c02b3972
diff --git a/apps/designer/package.json b/apps/designer/package.json
index c23a3ced3d..68faa15f0d 100644
--- a/apps/designer/package.json
+++ b/apps/designer/package.json
@@ -4,7 +4,7 @@
"description": "Webstudio Designer UI as a service",
"scripts": {
"build": "remix build",
- "dev": "remix dev",
+ "dev": "migrations --dev migrate && remix dev",
"start": "remix-serve build",
"typecheck": "tsc -b",
"lint": "eslint . --ext .ts,.tsx --max-warnings 0",
@@ -15,7 +15,8 @@
"storybook:run": "start-storybook -p 6006",
"storybook:build": "build-storybook",
"migrations": "migrations --dev",
- "migrations:deploy": "migrations migrate"
+ "migrate": "migrations migrate --dev --skip-confirmation",
+ "migrations:deploy": "migrations migrate --skip-confirmation"
},
"dependencies": {
"@lexical/react": "^0.3.5",
diff --git a/package.json b/package.json
index 839e816f11..0598f18ac0 100644
--- a/package.json
+++ b/package.json
@@ -12,6 +12,7 @@
"build": "turbo run build",
"checks": "turbo run checks",
"dev": "turbo run dev --parallel",
+ "migrate": "turbo run migrate",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"prepare": "husky install",
"storybook": "turbo run storybook:run"
diff --git a/packages/prisma-client/migrations-cli/README.md b/packages/prisma-client/migrations-cli/README.md
index 31b232549f..0236ca05f2 100644
--- a/packages/prisma-client/migrations-cli/README.md
+++ b/packages/prisma-client/migrations-cli/README.md
@@ -6,9 +6,12 @@ This flag can be added to any command. It informs the CLI that it’s used in a
- automatically loads variables from `.env` files,
- uses a lockfile,
-- asks for confirmation before applying migrations,
- allows resetting the database using the `reset` command.
+### `--skip-confirmation`
+
+This flag can be added to any command. It prevents the CLI from asking for confirmation before executing the command.
+
### `create-schema <name>`
Example: `$ migrations create-schema add_projects_table`
diff --git a/packages/prisma-client/migrations-cli/args.ts b/packages/prisma-client/migrations-cli/args.ts
index 08a3ae1e8b..f5e33bd208 100644
--- a/packages/prisma-client/migrations-cli/args.ts
+++ b/packages/prisma-client/migrations-cli/args.ts
@@ -1,5 +1,5 @@
import minimist from "minimist";
export default minimist(process.argv.slice(2), {
- boolean: ["dev"],
-}) as { _: string[]; dev: boolean };
+ boolean: ["dev", "skip-confirmation"],
+}) as { _: string[]; dev: boolean; "skip-confirmation": boolean };
diff --git a/packages/prisma-client/migrations-cli/cli.ts b/packages/prisma-client/migrations-cli/cli.ts
index 84346d9fdc..7ed398aeca 100755
--- a/packages/prisma-client/migrations-cli/cli.ts
+++ b/packages/prisma-client/migrations-cli/cli.ts
@@ -18,6 +18,7 @@ Commands:
Arguments
--dev — Lets the CLI know that it's running in a development environment
+ --skip-confirmation — Skips the confirmation prompt when running a dangerous command
`;
const main = async () => {
diff --git a/packages/prisma-client/migrations-cli/commands.ts b/packages/prisma-client/migrations-cli/commands.ts
index 0055666f26..d4e38ff4cb 100644
--- a/packages/prisma-client/migrations-cli/commands.ts
+++ b/packages/prisma-client/migrations-cli/commands.ts
@@ -18,6 +18,10 @@ const confirm = async (
message: string,
defaultResult = false
): Promise<boolean> => {
+ if (args["skip-confirmation"]) {
+ return true;
+ }
+
// Not using `node:readline/promises` because it's experimental.
return new Promise((resolve) => {
const rl = readline.createInterface({
@@ -39,7 +43,7 @@ const confirm = async (
});
};
-const ensureUserWantiToContinue = async (defaultResult = false) => {
+const ensureUserWantsToContinue = async (defaultResult = false) => {
const result = await confirm("Continue?", defaultResult);
if (result === false) {
logger.info("Aborted.");
@@ -293,7 +297,7 @@ export const migrate = async () => {
logger.info(` - ${migration.name}`);
}
logger.info("");
- await ensureUserWantiToContinue(true);
+ await ensureUserWantsToContinue(true);
}
await up();
@@ -358,7 +362,7 @@ export const resolve = async ({
);
logger.info("");
- await ensureUserWantiToContinue();
+ await ensureUserWantsToContinue();
if (resolveAs === "applied") {
await prismaMigrations.setApplied(migrationName);
@@ -387,7 +391,7 @@ export const reset = async () => {
logger.info("and run all migrations from scratch!");
logger.info("");
- await ensureUserWantiToContinue();
+ await ensureUserWantsToContinue();
await prismaMigrations.resetDatabase();
await up();
diff --git a/turbo.json b/turbo.json
index 7c9bd87ce1..6659d4704d 100644
--- a/turbo.json
+++ b/turbo.json
@@ -10,6 +10,9 @@
"dev": {
"cache": false
},
+ "migrate": {
+ "cache": false
+ },
"storybook:run": {
"cache": false
}