Migration_20221028_105818.php
3 months ago
Migration_20221110_151621.php
3 years ago
Migration_20230111_120000.php
2 years ago
Migration_20230111_130000.php
3 years ago
Migration_20230215_050813.php
3 months ago
Migration_20230221_200520.php
3 years ago
Migration_20230421_135915.php
3 years ago
Migration_20230503_210945.php
3 years ago
Migration_20230605_174836.php
3 years ago
Migration_20230703_105957.php
3 years ago
Migration_20230716_130221_Db.php
2 years ago
Migration_20230824_054259_Db.php
2 years ago
Migration_20230831_124214_Db.php
2 years ago
Migration_20230831_143755_Db.php
1 year ago
Migration_20240119_113943_Db.php
2 years ago
Migration_20240617_122847_Db.php
2 years ago
Migration_20240725_182318_Db.php
2 years ago
Migration_20241007_170437_Db.php
1 year ago
Migration_20241108_103249_Db.php
3 months ago
Migration_20250903_151331_Db.php
11 months ago
Migration_20250926_153050_Db.php
10 months ago
Migration_20260415_090055_Db.php
3 months ago
Migration_20260427_100000.php
3 months ago
Migration_20260428_120000.php
3 months ago
Migration_20260430_103000_Db.php
3 months ago
Migration_20260430_120000.php
3 months ago
Migration_20260504_120000_Db.php
3 months ago
Migration_20260514_120000_Db.php
3 months ago
Migration_20260609_120000_Db.php
2 months ago
Migration_20260610_120000_Db.php
1 month ago
Migration_20260622_120000_Db.php
1 month ago
Migration_20260709_120000_Db.php
1 month ago
Migration_20260715_100000_Db.php
1 month ago
index.php
3 years ago
Migration_20221110_151621.php
77 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace MailPoet\Migrations\Db; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\Migrator\DbMigration; |
| 9 | |
| 10 | /** |
| 11 | * The "created_at" column must be NULL in some tables to avoid "there can be only one |
| 12 | * TIMESTAMP column with CURRENT_TIMESTAMP" error on MySQL version < 5.6.5 that occurs |
| 13 | * even when other timestamp is simply "NOT NULL". |
| 14 | * |
| 15 | * Additionally, having multiple timestamp columns with "NOT NULL" seems to produce the |
| 16 | * following error in some SQL modes: |
| 17 | * SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'updated_at'" |
| 18 | */ |
| 19 | class Migration_20221110_151621 extends DbMigration { |
| 20 | public function run(): void { |
| 21 | $this->createTable('automations', [ |
| 22 | 'id int(11) unsigned NOT NULL AUTO_INCREMENT', |
| 23 | 'name varchar(191) NOT NULL', |
| 24 | 'author bigint NOT NULL', |
| 25 | 'status varchar(191) NOT NULL', |
| 26 | 'created_at timestamp NULL', // must be NULL, see comment at the top |
| 27 | 'updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', |
| 28 | 'activated_at timestamp NULL', |
| 29 | 'deleted_at timestamp NULL', |
| 30 | 'PRIMARY KEY (id)', |
| 31 | ]); |
| 32 | |
| 33 | $this->createTable('automation_versions', [ |
| 34 | 'id int(11) unsigned NOT NULL AUTO_INCREMENT', |
| 35 | 'automation_id int(11) unsigned NOT NULL', |
| 36 | 'steps longtext', |
| 37 | 'created_at timestamp NULL', // must be NULL, see comment at the top |
| 38 | 'updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', |
| 39 | 'PRIMARY KEY (id)', |
| 40 | 'INDEX (automation_id)', |
| 41 | ]); |
| 42 | |
| 43 | $this->createTable('automation_triggers', [ |
| 44 | 'automation_id int(11) unsigned NOT NULL', |
| 45 | 'trigger_key varchar(191)', |
| 46 | 'PRIMARY KEY (automation_id, trigger_key)', |
| 47 | ]); |
| 48 | |
| 49 | $this->createTable('automation_runs', [ |
| 50 | 'id int(11) unsigned NOT NULL AUTO_INCREMENT', |
| 51 | 'automation_id int(11) unsigned NOT NULL', |
| 52 | 'version_id int(11) unsigned NOT NULL', |
| 53 | 'trigger_key varchar(191) NOT NULL', |
| 54 | 'status varchar(191) NOT NULL', |
| 55 | 'created_at timestamp NULL', // must be NULL, see comment at the top |
| 56 | 'updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', |
| 57 | 'subjects longtext', |
| 58 | 'next_step_id varchar(191)', |
| 59 | 'PRIMARY KEY (id)', |
| 60 | 'INDEX (automation_id, status)', |
| 61 | ]); |
| 62 | |
| 63 | $this->createTable('automation_run_logs', [ |
| 64 | 'id int(11) unsigned NOT NULL AUTO_INCREMENT', |
| 65 | 'automation_run_id int(11) unsigned NOT NULL', |
| 66 | 'step_id varchar(191) NOT NULL', |
| 67 | 'status varchar(191) NOT NULL', |
| 68 | 'started_at timestamp NOT NULL', |
| 69 | 'completed_at timestamp NULL DEFAULT NULL', |
| 70 | 'error longtext', |
| 71 | 'data longtext', |
| 72 | 'PRIMARY KEY (id)', |
| 73 | 'INDEX (automation_run_id)', |
| 74 | ]); |
| 75 | } |
| 76 | } |
| 77 |