fix: change BIGINT UNSIGNED to BIGINT, INT columns map to i32 not i64

This commit is contained in:
NixReaper
2026-04-25 20:59:41 -05:00
parent 144d08a581
commit 09b043d764
2 changed files with 63 additions and 63 deletions
+18 -18
View File
@@ -1,6 +1,6 @@
-- Users (panel logins: admin + per-account users)
CREATE TABLE IF NOT EXISTS users (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
id BIGINT NOT NULL AUTO_INCREMENT,
username VARCHAR(64) NOT NULL,
email VARCHAR(255) NOT NULL,
password_hash VARCHAR(255) NOT NULL,
@@ -14,8 +14,8 @@ CREATE TABLE IF NOT EXISTS users (
-- Hosting accounts
CREATE TABLE IF NOT EXISTS accounts (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
user_id BIGINT UNSIGNED,
id BIGINT NOT NULL AUTO_INCREMENT,
user_id BIGINT,
username VARCHAR(64) NOT NULL,
domain VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
@@ -34,8 +34,8 @@ CREATE TABLE IF NOT EXISTS accounts (
-- Domains / DNS zones
CREATE TABLE IF NOT EXISTS domains (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
account_id BIGINT UNSIGNED,
id BIGINT NOT NULL AUTO_INCREMENT,
account_id BIGINT,
name VARCHAR(255) NOT NULL,
type ENUM('main','addon','parked','subdomain') NOT NULL DEFAULT 'main',
status ENUM('active','inactive') NOT NULL DEFAULT 'active',
@@ -47,9 +47,9 @@ CREATE TABLE IF NOT EXISTS domains (
-- DNS records
CREATE TABLE IF NOT EXISTS dns_records (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
domain_id BIGINT UNSIGNED NOT NULL,
type VARCHAR(10) NOT NULL, -- A, AAAA, CNAME, MX, TXT, NS, SRV
id BIGINT NOT NULL AUTO_INCREMENT,
domain_id BIGINT NOT NULL,
type VARCHAR(10) NOT NULL,
name VARCHAR(255) NOT NULL,
content VARCHAR(512) NOT NULL,
ttl INT NOT NULL DEFAULT 3600,
@@ -61,8 +61,8 @@ CREATE TABLE IF NOT EXISTS dns_records (
-- MySQL/MariaDB databases owned by accounts
CREATE TABLE IF NOT EXISTS account_databases (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
account_id BIGINT UNSIGNED NOT NULL,
id BIGINT NOT NULL AUTO_INCREMENT,
account_id BIGINT NOT NULL,
db_name VARCHAR(64) NOT NULL,
db_user VARCHAR(64) NOT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -73,8 +73,8 @@ CREATE TABLE IF NOT EXISTS account_databases (
-- Email accounts
CREATE TABLE IF NOT EXISTS email_accounts (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
account_id BIGINT UNSIGNED NOT NULL,
id BIGINT NOT NULL AUTO_INCREMENT,
account_id BIGINT NOT NULL,
address VARCHAR(255) NOT NULL,
password_hash VARCHAR(255) NOT NULL,
quota_mb INT NOT NULL DEFAULT 1024,
@@ -86,8 +86,8 @@ CREATE TABLE IF NOT EXISTS email_accounts (
-- FTP accounts
CREATE TABLE IF NOT EXISTS ftp_accounts (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
account_id BIGINT UNSIGNED NOT NULL,
id BIGINT NOT NULL AUTO_INCREMENT,
account_id BIGINT NOT NULL,
username VARCHAR(64) NOT NULL,
home_dir VARCHAR(512) NOT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -98,8 +98,8 @@ CREATE TABLE IF NOT EXISTS ftp_accounts (
-- SSL certificates
CREATE TABLE IF NOT EXISTS ssl_certificates (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
account_id BIGINT UNSIGNED,
id BIGINT NOT NULL AUTO_INCREMENT,
account_id BIGINT,
domain VARCHAR(255) NOT NULL,
issuer VARCHAR(64) NOT NULL DEFAULT 'letsencrypt',
cert_path VARCHAR(512),
@@ -114,8 +114,8 @@ CREATE TABLE IF NOT EXISTS ssl_certificates (
-- Backup jobs
CREATE TABLE IF NOT EXISTS backups (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
account_id BIGINT UNSIGNED,
id BIGINT NOT NULL AUTO_INCREMENT,
account_id BIGINT,
type ENUM('full','incremental') NOT NULL DEFAULT 'full',
status ENUM('pending','running','completed','failed') NOT NULL DEFAULT 'pending',
size_bytes BIGINT,
+6 -6
View File
@@ -11,8 +11,8 @@ pub struct Account {
pub domain: String,
pub email: String,
pub package_name: String,
pub disk_quota_mb: i64,
pub bandwidth_mb: i64,
pub disk_quota_mb: i32, // INT column → i32
pub bandwidth_mb: i32, // INT column → i32
pub status: String,
pub created_at: NaiveDateTime,
}
@@ -24,8 +24,8 @@ pub struct CreateAccountRequest {
pub email: String,
pub password: String,
pub package_name: Option<String>,
pub disk_quota_mb: Option<i64>,
pub bandwidth_mb: Option<i64>,
pub disk_quota_mb: Option<i32>,
pub bandwidth_mb: Option<i32>,
}
pub async fn list_accounts(
@@ -71,8 +71,8 @@ pub async fn create_account(
let _ = std::fs::create_dir_all(format!("/home/{}/public_html", body.username));
let package_name = body.package_name.unwrap_or_else(|| "Default".into());
let disk_quota_mb = body.disk_quota_mb.unwrap_or(10240);
let bandwidth_mb = body.bandwidth_mb.unwrap_or(0);
let disk_quota_mb: i32 = body.disk_quota_mb.unwrap_or(10240);
let bandwidth_mb: i32 = body.bandwidth_mb.unwrap_or(0);
let insert_id: u64 = sqlx::query(
"INSERT INTO accounts (username, domain, email, password_hash, package_name, disk_quota_mb, bandwidth_mb, status)