hasTable('mcs_config')) { $table = $schema->createTable('mcs_config'); $table->addColumn('id', Types::BIGINT, [ 'autoincrement' => true, 'notnull' => true, 'unsigned' => true, ]); $table->addColumn('user_id', Types::STRING, [ 'notnull' => true, 'length' => 64, ]); $table->addColumn('enabled', Types::SMALLINT, [ 'notnull' => true, 'default' => 0, 'unsigned' => true, ]); $table->addColumn('mail_account_id', Types::BIGINT, [ 'notnull' => false, 'unsigned' => true, ]); $table->addColumn('calendar_uri', Types::STRING, [ 'notnull' => false, 'length' => 255, ]); $table->addColumn('auto_accept', Types::SMALLINT, [ 'notnull' => true, 'default' => 0, 'unsigned' => true, ]); $table->addColumn('sync_interval', Types::INTEGER, [ 'notnull' => true, 'default' => 600, 'unsigned' => true, ]); $table->addColumn('created_at', Types::STRING, [ 'notnull' => true, 'length' => 32, ]); $table->addColumn('updated_at', Types::STRING, [ 'notnull' => true, 'length' => 32, ]); $table->setPrimaryKey(['id']); $table->addUniqueIndex(['user_id'], 'mcs_config_user_idx'); } else { // Table exists — ensure sync_interval column is present (upgrade path) $table = $schema->getTable('mcs_config'); if (!$table->hasColumn('sync_interval')) { $table->addColumn('sync_interval', Types::INTEGER, [ 'notnull' => true, 'default' => 600, 'unsigned' => true, ]); } } if (!$schema->hasTable('mcs_log')) { $table = $schema->createTable('mcs_log'); $table->addColumn('id', Types::BIGINT, [ 'autoincrement' => true, 'notnull' => true, 'unsigned' => true, ]); $table->addColumn('user_id', Types::STRING, [ 'notnull' => true, 'length' => 64, ]); $table->addColumn('event_uid', Types::STRING, [ 'notnull' => true, 'length' => 512, ]); $table->addColumn('event_summary', Types::STRING, [ 'notnull' => false, 'length' => 512, ]); $table->addColumn('action', Types::STRING, [ 'notnull' => true, 'length' => 64, ]); $table->addColumn('attendee_email', Types::STRING, [ 'notnull' => false, 'length' => 255, ]); $table->addColumn('from_email', Types::STRING, [ 'notnull' => false, 'length' => 255, ]); $table->addColumn('message', Types::TEXT, [ 'notnull' => false, ]); $table->addColumn('created_at', Types::STRING, [ 'notnull' => true, 'length' => 32, ]); $table->setPrimaryKey(['id']); $table->addIndex(['user_id', 'created_at'], 'mcs_log_user_date_idx'); } if (!$schema->hasTable('mcs_processed')) { $table = $schema->createTable('mcs_processed'); $table->addColumn('id', Types::BIGINT, [ 'autoincrement' => true, 'notnull' => true, 'unsigned' => true, ]); $table->addColumn('user_id', Types::STRING, [ 'notnull' => true, 'length' => 64, ]); $table->addColumn('mail_account_id', Types::BIGINT, [ 'notnull' => true, 'unsigned' => true, ]); $table->addColumn('message_id', Types::STRING, [ 'notnull' => true, 'length' => 512, ]); $table->addColumn('processed_at', Types::STRING, [ 'notnull' => true, 'length' => 32, ]); $table->setPrimaryKey(['id']); $table->addUniqueIndex(['user_id', 'mail_account_id', 'message_id'], 'mcs_proc_unique_idx'); $table->addIndex(['user_id'], 'mcs_proc_user_idx'); } return $schema; } }