From f04b33636d7779fc4d9227e3674c1939ad012595 Mon Sep 17 00:00:00 2001 From: Germain Italic <17506424+germain-italic@users.noreply.github.com> Date: Sat, 25 Nov 2023 23:02:49 +0400 Subject: [PATCH] Feature/import schema (#70) * remove empty trailing spaces * add a button to create schema on the relations page, aligned with flex * import an sql schema from copy/pasting * option to disable foreign key checks and drop existing tables * read a list of .sql files to import as a schema * wording --- .gitignore | 4 +- core/relations.php | 4 +- core/schema.php | 140 +++++++++++++++++++++++++++++++++++++++++++++ schema/.gitkeep | 0 4 files changed, 146 insertions(+), 2 deletions(-) create mode 100644 core/schema.php create mode 100644 schema/.gitkeep diff --git a/.gitignore b/.gitignore index 6bd94b5..746b147 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -core/app/ \ No newline at end of file +core/app/ +schema/* +!schema/.gitkeep \ No newline at end of file diff --git a/core/relations.php b/core/relations.php index e349794..29b1c2d 100644 --- a/core/relations.php +++ b/core/relations.php @@ -246,7 +246,9 @@
On this page you can add new or delete existing table relations i.e. foreign keys. Having foreign keys will result in Cruddiy forms with cascading deletes/updates and dropdown fields populated by foreign keys. If it is not clear what you want or need to do here, it is SAFER to skip this step and move to the next step! You can always come back later and regenerate new forms.
-
+ + + Import Schema or Dump
diff --git a/core/schema.php b/core/schema.php new file mode 100644 index 0000000..0a4c66e --- /dev/null +++ b/core/schema.php @@ -0,0 +1,140 @@ +getMessage(); + } + + // Check for any errors that occurred after the last executed query + if ($error = mysqli_error($link)) { + $errors['schema'][] = $error; + } + + mysqli_close($link); + + if (!isset($errors['schema'])) { + header('location:relations.php'); + exit(); + } +} +?> + + + + + CRUD generator + + + + +
+
+
+
+
+

Import schema

+ + + + + + + + +
+ + +
+ + + + Place your .sql files in the schema/ folder in the project root. + +
+ + +
+ + +
+ +
+ > + +
+
+ +
+
+
+
+
+
+
+ + + + + + + diff --git a/schema/.gitkeep b/schema/.gitkeep new file mode 100644 index 0000000..e69de29