diff --git a/code/Extension/UpgradePolymorphicExtension.php b/code/Extension/UpgradePolymorphicExtension.php
index b77b114..64c965e 100644
--- a/code/Extension/UpgradePolymorphicExtension.php
+++ b/code/Extension/UpgradePolymorphicExtension.php
@@ -15,7 +15,7 @@ use SilverStripe\UserForms\Model\UserDefinedForm;
use SilverStripe\UserForms\UserForm;
/**
- * This extension provides a hook that runs during a dev/build which will check for existing data in various
+ * This extension provides a hook that runs when building the db which will check for existing data in various
* polymorphic relationship fields for userforms models, and ensure that the data is correct.
*
* Various `Parent` relationships in silverstripe/userforms for SilverStripe 3 were mapped directly to UserDefinedForm
@@ -83,9 +83,9 @@ class UpgradePolymorphicExtension extends Extension
$entry->write();
$updated++;
} catch (ValidationException $ex) {
- // no-op, allow the rest of dev/build to continue. There may be an error indicating that the
+ // no-op, allow the rest of the db build to continue. There may be an error indicating that the
// object's class doesn't exist, which can be fixed by {@link DatabaseAdmin::doBuild} and this
- // logic will work the next time dev/build is run.
+ // logic will work the next time the db is built.
}
}
}
diff --git a/code/Task/UserFormsColumnCleanTask.php b/code/Task/UserFormsColumnCleanTask.php
index e62a086..5c28406 100644
--- a/code/Task/UserFormsColumnCleanTask.php
+++ b/code/Task/UserFormsColumnCleanTask.php
@@ -2,10 +2,13 @@
namespace SilverStripe\UserForms\Task;
-use SilverStripe\Dev\MigrationTask;
+use SilverStripe\Dev\BuildTask;
+use SilverStripe\PolyExecution\PolyOutput;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DB;
use SilverStripe\UserForms\Model\EditableFormField;
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Input\InputInterface;
/**
* UserForms Column Clean Task
@@ -15,11 +18,13 @@ use SilverStripe\UserForms\Model\EditableFormField;
* @package userforms
*/
-class UserFormsColumnCleanTask extends MigrationTask
+class UserFormsColumnCleanTask extends BuildTask
{
- protected $title = 'UserForms EditableFormField Column Clean task';
+ protected static string $commandName = 'userforms-column-clean';
- protected $description = 'Removes unused columns from EditableFormField for MySQL databases;';
+ protected string $title = 'UserForms EditableFormField Column Clean task';
+
+ protected static string $description = 'Removes unused columns from EditableFormField for MySQL databases;';
protected $tables = [EditableFormField::class];
@@ -28,7 +33,7 @@ class UserFormsColumnCleanTask extends MigrationTask
/**
* Publish the existing forms.
*/
- public function run($request)
+ protected function execute(InputInterface $input, PolyOutput $output): int
{
$schema = DataObject::getSchema();
@@ -40,28 +45,29 @@ class UserFormsColumnCleanTask extends MigrationTask
$query = "SHOW TABLES LIKE 'Backup_$db'";
$tableExists = DB::query($query)->value();
if ($tableExists != null) {
- echo "Tasks run already on $db exiting";
- return;
+ $output->writeln("Tasks run already on $db exiting");
+ return Command::SUCCESS;
}
$backedUp = 0;
foreach ($liveColumns as $index => $column) {
if ($backedUp == 0) {
- echo "Backing up $db
";
- echo "Creating Backup_$db
";
+ $output->writeln("Backing up $db
");
+ $output->writeln("Creating Backup_$db
");
// backup table
$query = "CREATE TABLE Backup_$db LIKE $db";
DB::query($query);
- echo "Populating Backup_$db
";
+ $output->writeln("Populating Backup_$db
");
$query = "INSERT Backup_$db SELECT * FROM $db";
DB::query($query);
$backedUp = 1;
}
if (!isset($columns[$column]) && !in_array($column, $this->keepColumns ?? [])) {
- echo "Dropping $column from $db
";
+ $output->writeln("Dropping $column from $db
");
$query = "ALTER TABLE $db DROP COLUMN $column";
DB::query($query);
}
}
}
+ return Command::SUCCESS;
}
}
diff --git a/code/UserForm.php b/code/UserForm.php
index 962fbf5..010d3c8 100644
--- a/code/UserForm.php
+++ b/code/UserForm.php
@@ -65,7 +65,7 @@ trait UserForm
private static $email_template_directory = 'silverstripe/userforms:templates/email/';
/**
- * Should this module automatically upgrade on dev/build?
+ * Should this module automatically upgrade on db build?
*
* @config
* @var bool
diff --git a/docs/en/01_installation.md b/docs/en/01_installation.md
index 814ba30..db1a93e 100644
--- a/docs/en/01_installation.md
+++ b/docs/en/01_installation.md
@@ -12,7 +12,7 @@ composer require silverstripe/userforms
## Configuration
-After installation, make sure you rebuild your database through `dev/build`.
+After installation, make sure you rebuild your database through `sake db:build --flush`.
You should see a new page type in the CMS called "User Defined Form". This has a new "Form" tab which has your form builder.
diff --git a/docs/en/03_troubleshooting.md b/docs/en/03_troubleshooting.md
index ea83de8..5c2d9be 100644
--- a/docs/en/03_troubleshooting.md
+++ b/docs/en/03_troubleshooting.md
@@ -6,11 +6,6 @@ title: Troubleshooting
Check the below if you have any issues during installation or use
-## Installation issues
-
-After installation make sure you have done a `dev/build` you may also need to flush the admin view by appending
-`?flush=1` to the URL, e.g. `https://example.com/admin?flush=1`
-
## Checkbox or radio group custom messages not showing
If your project has a custom template for `UserFormsCheckboxSetField.ss` or `UserFormsOptionSetField.ss`, then you will need to ensure they include `$Top.getValidationAttributesHTML().RAW`. See
@@ -28,7 +23,7 @@ Currently it only supports MySQL and when it is run it queries the EditableFormF
it then grabs the columns for the live database. It will create a backup of the table and then remove any columns that
are surplus.
-To run the task, log in as an administrator and go to `https://example.com/dev/tasks/UserFormsColumnCleanTask` in your browser, or run `sake dev/tasks/UserFormsColumnCleanTask` from the command line.
+To run the task, log in as an administrator and go to `https://example.com/dev/tasks/userforms-column-clean` in your browser, or run `sake tasks:userforms-column-clean` from the command line.
## My CSV export times out or runs out of memory