Files
WooAApanel/includes/class-wooaapanel-installer.php
Malin 8bb96b9048 feat: initial WooAApanel plugin
Full WooCommerce plugin for aaPanel hosting management:
- aaPanel API client (all website + database endpoints)
- Admin: server management, site/DB assignments, full site/DB management panels
- Customer My Account: web hosting tab with sites and databases
- WooDomains PowerDNS integration for DNS management
- WooCommerce order auto-provisioning (product → server linking)
- Permission model: admin has all actions, customers have scoped access

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 12:48:06 +01:00

57 lines
2.0 KiB
PHP

<?php
defined( 'ABSPATH' ) || exit;
class WooAApanel_Installer {
public static function install(): void {
global $wpdb;
$charset = $wpdb->get_charset_collate();
// aaPanel server instances.
$servers_sql = "CREATE TABLE {$wpdb->prefix}wooaapanel_servers (
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(100) NOT NULL,
url VARCHAR(500) NOT NULL,
api_key VARCHAR(500) NOT NULL,
active TINYINT(1) NOT NULL DEFAULT 1,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
) $charset;";
// Site (PHP project) assignments per customer.
$sites_sql = "CREATE TABLE {$wpdb->prefix}wooaapanel_site_assignments (
id INT NOT NULL AUTO_INCREMENT,
customer_id BIGINT NOT NULL,
server_id INT NOT NULL,
site_name VARCHAR(255) NOT NULL,
domain VARCHAR(255) NOT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id),
KEY idx_customer (customer_id),
KEY idx_server (server_id),
UNIQUE KEY uniq_site (server_id, site_name)
) $charset;";
// Database assignments per customer.
$dbs_sql = "CREATE TABLE {$wpdb->prefix}wooaapanel_db_assignments (
id INT NOT NULL AUTO_INCREMENT,
customer_id BIGINT NOT NULL,
server_id INT NOT NULL,
db_name VARCHAR(255) NOT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id),
KEY idx_customer (customer_id),
KEY idx_server (server_id),
UNIQUE KEY uniq_db (server_id, db_name)
) $charset;";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta( $servers_sql );
dbDelta( $sites_sql );
dbDelta( $dbs_sql );
update_option( 'wooaapanel_db_version', WOOAAPANEL_VERSION );
}
}