# fluentform/1.2.4/app/Databases/Migrations/FormAnalytics.php

Fluent Forms – Customizable Contact Forms, Survey, Quiz, &amp; Conversational Form Builder, version 1.2.4. 49 lines.

- Page: https://pluginprobe.com/plugins/fluentform/1.2.4/code/app/Databases/Migrations/FormAnalytics.php
- Raw: https://pluginprobe.com/plugins/fluentform/1.2.4/raw/app/Databases/Migrations/FormAnalytics.php
- Modified: 2017-12-29T16:40:50+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/fluentform/1.2.4/code/app/Databases/Migrations/FormAnalytics.php#L10-L20`.

```php
<?php

namespace FluentForm\App\Databases\Migrations;

class FormAnalytics
{
	
    /**
     * Migrate the table.
     *
     * @return void
     */
    public static function migrate()
    {
        global $wpdb;

        $charsetCollate = $wpdb->get_charset_collate();

        $table = $wpdb->prefix.'fluentform_form_analytics';

        $formTable = $wpdb->prefix.'fluentform_forms';

        if ($wpdb->get_var("SHOW TABLES LIKE '$table'") != $table) {
            $sql = "CREATE TABLE $table (
			  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
			  `form_id` INT UNSIGNED NULL,
			  `user_id` INT UNSIGNED NULL,
			  `source_url` VARCHAR(255) NOT NULL,
			  `platform` CHAR(30) NULL,
			  `browser` CHAR(30) NULL,
			  `city` VARCHAR (100) NULL,
			  `country` VARCHAR (100) NULL,
			  `ip` CHAR(15) NULL,
			  `count` INT DEFAULT 1,
			  `created_at` TIMESTAMP NULL,
			  PRIMARY KEY (`id`),
			  INDEX `fluent_analytics_form_id_idx` (`form_id` ASC),
			  CONSTRAINT `fk_fluent_form_meta_analytics_id`
			    FOREIGN KEY (`form_id`)
			    REFERENCES $formTable (`id`)
			    ON DELETE CASCADE
			    ON UPDATE CASCADE) $charsetCollate;";

            require_once(ABSPATH.'wp-admin/includes/upgrade.php');

            dbDelta($sql);
        }
    }
}
```
