prefix.DB::$namespace.'_automation_logs'; } public function __construct() { parent::__construct(); $this->table_name = $this->prefix.'_automation_logs'; $this->primary_key = 'id'; $this->version = '1.0'; } public function sql_create() { return "CREATE TABLE {$this->table_name} ( id bigint(20) NOT NULL AUTO_INCREMENT, restaurant_id bigint(20) DEFAULT NULL, booking_id bigint(20) DEFAULT NULL, automation_type varchar(100) NOT NULL, action varchar(100) NOT NULL, old_status varchar(50) DEFAULT NULL, new_status varchar(50) DEFAULT NULL, executed_at datetime NOT NULL, details text DEFAULT NULL, PRIMARY KEY (id), KEY `automation_logs_restaurant_id_foreign` (`restaurant_id`), CONSTRAINT `automation_logs_restaurant_id_foreign` FOREIGN KEY (`restaurant_id`) REFERENCES `{$this->prefix}_restaurants` (`id`) ON DELETE CASCADE, KEY `automation_logs_booking_id_foreign` (`booking_id`), CONSTRAINT `automation_logs_booking_id_foreign` FOREIGN KEY (`booking_id`) REFERENCES `{$this->prefix}_bookings` (`id`) ON DELETE CASCADE, KEY `automation_logs_type_action` (`automation_type`, `action`), KEY `automation_logs_executed_at` (`executed_at`) )"; } public function sql_update_columns_releases() { $queries = []; $queries['134'][] = "ALTER TABLE {$this->table_name} ADD idempotency_key varchar(64) DEFAULT NULL"; $queries['134'][] = "ALTER TABLE {$this->table_name} ADD UNIQUE KEY idempotency_key (idempotency_key)"; $this->run_queries_updates($queries); } } SRR_DB_Automation_Logs::init();