cloudlog/application/migrations/268_create_plugins_table.php
Peter Goodhall 4cfab6fe4e Add plugin system and Plugin Manager
Introduce a plugin framework and management UI: adds Plugin Manager controller, Plugin_awards controller, Plugin_manager and Cloudlog_hooks libraries, Plugins_model, migration (268) to create the plugins table, and views for plugin manager and award pages. Integrates hooks into Logbook_model (qso.filter.before_save, qso.action.after_save, qso.action.after_edit), updates header to show award plugin entries and a Plugin Manager menu link, and bumps migration_version to 268. Also adds .gitignore rules, plugin index placeholder, docs and example plugin packages. The Plugin Manager supports uploading/installing ZIP packages, safe extraction, manifest validation, enable/disable/delete actions, and CSRF protection.
2026-04-29 22:33:22 +01:00

69 lines
2.1 KiB
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Migration_create_plugins_table extends CI_Migration {
public function up()
{
if (!$this->db->table_exists('plugins')) {
$this->dbforge->add_field(array(
'id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'auto_increment' => TRUE,
),
'plugin_slug' => array(
'type' => 'VARCHAR',
'constraint' => 120,
'null' => FALSE,
),
'plugin_name' => array(
'type' => 'VARCHAR',
'constraint' => 255,
'null' => FALSE,
),
'plugin_version' => array(
'type' => 'VARCHAR',
'constraint' => 60,
'null' => FALSE,
'default' => '1.0.0',
),
'plugin_description' => array(
'type' => 'TEXT',
'null' => TRUE,
),
'plugin_status' => array(
'type' => 'VARCHAR',
'constraint' => 16,
'null' => FALSE,
'default' => 'disabled',
),
'plugin_manifest' => array(
'type' => 'MEDIUMTEXT',
'null' => TRUE,
),
'installed_at' => array(
'type' => 'DATETIME',
'null' => FALSE,
),
'updated_at' => array(
'type' => 'DATETIME',
'null' => FALSE,
),
));
$this->dbforge->add_key('id', TRUE);
$this->dbforge->add_key('plugin_slug', TRUE);
$this->dbforge->create_table('plugins');
}
}
public function down()
{
if ($this->db->table_exists('plugins')) {
$this->dbforge->drop_table('plugins');
}
}
}