Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lara28580's avatar

How to prevent statamic to deleted the forms submissions on every deployment?

I have the problem that my users' form submissions are deleted with every deployment. How can I prevent this? Could someone help me with this?

0 likes
8 replies
LaryAI's avatar
Level 58

To prevent Statamic from deleting form submissions on every deployment, you need to ensure that the storage location for form submissions is not overwritten during the deployment process. Here are a few steps you can take to achieve this:

  1. Use a Persistent Storage Location: By default, Statamic stores form submissions in the storage/forms directory. You can configure your deployment process to exclude this directory from being overwritten.

  2. Configure Deployment Tool: If you are using a deployment tool like Laravel Forge, Envoyer, or any CI/CD pipeline, you can configure it to preserve the storage/forms directory. For example, in Laravel Forge, you can add a deployment hook to create a symlink to a persistent storage location.

  3. Use a Database for Form Submissions: Another approach is to store form submissions in a database instead of the file system. This way, the submissions are not affected by file system changes during deployment.

Here is an example of how you can configure Statamic to use a database for form submissions:

  1. Install the Database Addon: First, you need to install the Statamic Database addon. You can do this via Composer:

    composer require statamic/eloquent-driver
    
  2. Configure the Addon: Next, you need to configure Statamic to use the database for form submissions. Update your config/statamic/eloquent-driver.php configuration file to include the forms driver:

    'forms' => [
        'driver' => 'eloquent',
    ],
    
  3. Run Migrations: Run the necessary migrations to create the database tables for form submissions:

    php artisan migrate
    
  4. Update Form Configuration: Finally, update your form configuration to use the database driver. In your form YAML file, set the store option to database:

    title: Contact Form
    store: database
    fields:
      - handle: name
        field:
          type: text
          display: Name
      - handle: email
        field:
          type: text
          display: Email
      - handle: message
        field:
          type: textarea
          display: Message
    

By following these steps, you can ensure that form submissions are stored in a database, which will not be affected by file system changes during deployment. This will prevent the loss of form submissions on every deployment.

If you prefer to stick with file-based storage, make sure to configure your deployment process to preserve the storage/forms directory.

I hope this helps! If you have any further questions, feel free to ask.

MohamedTammam's avatar

That's odd and not by default. Please share your deployment script.

1 like
MohamedTammam's avatar

@SmokeTM Then you're probably having storage/forms path in your .gitignore and that's why they have been removed with every deploy.

Three solutions in my mind:

  1. Remove the storage/form from .gitignore
  2. Change form submission storage path (from config/statami/forms.php submission)
  3. Modify your deployment script to not reset the files for each deployment
1 like

Please or to participate in this conversation.