chore: initialize repository with deployment baseline
This commit is contained in:
1352
backend/prisma/migrations/20260417120000_init/migration.sql
Normal file
1352
backend/prisma/migrations/20260417120000_init/migration.sql
Normal file
File diff suppressed because it is too large
Load Diff
1
backend/prisma/migrations/migration_lock.toml
Normal file
1
backend/prisma/migrations/migration_lock.toml
Normal file
@@ -0,0 +1 @@
|
||||
provider = "postgresql"
|
||||
1205
backend/prisma/schema.prisma
Normal file
1205
backend/prisma/schema.prisma
Normal file
File diff suppressed because it is too large
Load Diff
184
backend/prisma/seed.js
Normal file
184
backend/prisma/seed.js
Normal file
@@ -0,0 +1,184 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const bcryptjs_1 = __importDefault(require("bcryptjs"));
|
||||
const client_1 = require("@prisma/client");
|
||||
const prisma = new client_1.PrismaClient();
|
||||
async function main() {
|
||||
const adminEmail = process.env.ADMIN_EMAIL ?? "admin@proxpanel.local";
|
||||
const adminPassword = process.env.ADMIN_PASSWORD ?? "ChangeMe123!";
|
||||
const password_hash = await bcryptjs_1.default.hash(adminPassword, 12);
|
||||
const tenant = await prisma.tenant.upsert({
|
||||
where: { slug: "default-tenant" },
|
||||
update: {},
|
||||
create: {
|
||||
name: "Default Tenant",
|
||||
slug: "default-tenant",
|
||||
owner_email: adminEmail,
|
||||
currency: client_1.Currency.NGN,
|
||||
payment_provider: client_1.PaymentProvider.PAYSTACK
|
||||
}
|
||||
});
|
||||
await prisma.user.upsert({
|
||||
where: { email: adminEmail },
|
||||
update: {
|
||||
role: client_1.Role.SUPER_ADMIN,
|
||||
password_hash,
|
||||
tenant_id: tenant.id
|
||||
},
|
||||
create: {
|
||||
email: adminEmail,
|
||||
full_name: "System Administrator",
|
||||
password_hash,
|
||||
role: client_1.Role.SUPER_ADMIN,
|
||||
tenant_id: tenant.id
|
||||
}
|
||||
});
|
||||
await prisma.setting.upsert({
|
||||
where: { key: "proxmox" },
|
||||
update: {},
|
||||
create: {
|
||||
key: "proxmox",
|
||||
type: "PROXMOX",
|
||||
value: {
|
||||
host: "",
|
||||
port: 8006,
|
||||
username: "root@pam",
|
||||
token_id: "",
|
||||
token_secret: "",
|
||||
verify_ssl: true
|
||||
}
|
||||
}
|
||||
});
|
||||
await prisma.setting.upsert({
|
||||
where: { key: "payment" },
|
||||
update: {},
|
||||
create: {
|
||||
key: "payment",
|
||||
type: "PAYMENT",
|
||||
value: {
|
||||
default_provider: "paystack",
|
||||
paystack_public: "",
|
||||
paystack_secret: "",
|
||||
flutterwave_public: "",
|
||||
flutterwave_secret: "",
|
||||
flutterwave_webhook_hash: "",
|
||||
callback_url: ""
|
||||
}
|
||||
}
|
||||
});
|
||||
await prisma.setting.upsert({
|
||||
where: { key: "provisioning" },
|
||||
update: {},
|
||||
create: {
|
||||
key: "provisioning",
|
||||
type: "GENERAL",
|
||||
value: {
|
||||
min_vmid: 100
|
||||
}
|
||||
}
|
||||
});
|
||||
await prisma.setting.upsert({
|
||||
where: { key: "backup" },
|
||||
update: {},
|
||||
create: {
|
||||
key: "backup",
|
||||
type: "GENERAL",
|
||||
value: {
|
||||
default_source: "local",
|
||||
default_storage: "local-lvm",
|
||||
max_restore_file_count: 100,
|
||||
pbs_enabled: false,
|
||||
pbs_host: "",
|
||||
pbs_datastore: "",
|
||||
pbs_namespace: "",
|
||||
pbs_verify_ssl: true
|
||||
}
|
||||
}
|
||||
});
|
||||
await prisma.billingPlan.upsert({
|
||||
where: { slug: "starter" },
|
||||
update: {},
|
||||
create: {
|
||||
name: "Starter",
|
||||
slug: "starter",
|
||||
description: "Entry plan for lightweight VM workloads",
|
||||
price_monthly: 12000,
|
||||
price_hourly: 12000 / 720,
|
||||
currency: client_1.Currency.NGN,
|
||||
cpu_cores: 2,
|
||||
ram_mb: 4096,
|
||||
disk_gb: 60,
|
||||
bandwidth_gb: 2000,
|
||||
features: ["basic-support", "daily-backups"]
|
||||
}
|
||||
});
|
||||
const ubuntuTemplate = await prisma.appTemplate.upsert({
|
||||
where: { slug: "ubuntu-22-04-golden" },
|
||||
update: {},
|
||||
create: {
|
||||
name: "Ubuntu 22.04 Golden",
|
||||
slug: "ubuntu-22-04-golden",
|
||||
template_type: "KVM_TEMPLATE",
|
||||
virtualization_type: "QEMU",
|
||||
source: "local:vztmpl/ubuntu-22.04-golden.qcow2",
|
||||
description: "Baseline hardened Ubuntu template",
|
||||
metadata: {
|
||||
os_family: "linux",
|
||||
os_version: "22.04"
|
||||
}
|
||||
}
|
||||
});
|
||||
const webGroup = await prisma.applicationGroup.upsert({
|
||||
where: { slug: "web-workloads" },
|
||||
update: {},
|
||||
create: {
|
||||
name: "Web Workloads",
|
||||
slug: "web-workloads",
|
||||
description: "HTTP-facing application services"
|
||||
}
|
||||
});
|
||||
await prisma.applicationGroupTemplate.upsert({
|
||||
where: {
|
||||
group_id_template_id: {
|
||||
group_id: webGroup.id,
|
||||
template_id: ubuntuTemplate.id
|
||||
}
|
||||
},
|
||||
update: {},
|
||||
create: {
|
||||
group_id: webGroup.id,
|
||||
template_id: ubuntuTemplate.id,
|
||||
priority: 10
|
||||
}
|
||||
});
|
||||
await prisma.backupPolicy.upsert({
|
||||
where: {
|
||||
id: "default-tenant-backup-policy"
|
||||
},
|
||||
update: {},
|
||||
create: {
|
||||
id: "default-tenant-backup-policy",
|
||||
tenant_id: tenant.id,
|
||||
max_files: 25,
|
||||
max_total_size_mb: 102400,
|
||||
max_protected_files: 5,
|
||||
allow_file_restore: true,
|
||||
allow_cross_vm_restore: true,
|
||||
allow_pbs_restore: true
|
||||
}
|
||||
});
|
||||
}
|
||||
main()
|
||||
.then(async () => {
|
||||
await prisma.$disconnect();
|
||||
})
|
||||
.catch(async (error) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error("Seed failed:", error);
|
||||
await prisma.$disconnect();
|
||||
process.exit(1);
|
||||
});
|
||||
//# sourceMappingURL=seed.js.map
|
||||
1
backend/prisma/seed.js.map
Normal file
1
backend/prisma/seed.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"seed.js","sourceRoot":"","sources":["seed.ts"],"names":[],"mappings":";;;;;AAAA,wDAA8B;AAC9B,2CAA+E;AAE/E,MAAM,MAAM,GAAG,IAAI,qBAAY,EAAE,CAAC;AAElC,KAAK,UAAU,IAAI;IACjB,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,uBAAuB,CAAC;IACtE,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,cAAc,CAAC;IACnE,MAAM,aAAa,GAAG,MAAM,kBAAM,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;IAE3D,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;QACxC,KAAK,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE;QACjC,MAAM,EAAE,EAAE;QACV,MAAM,EAAE;YACN,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,gBAAgB;YACtB,WAAW,EAAE,UAAU;YACvB,QAAQ,EAAE,iBAAQ,CAAC,GAAG;YACtB,gBAAgB,EAAE,wBAAe,CAAC,QAAQ;SAC3C;KACF,CAAC,CAAC;IAEH,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;QACvB,KAAK,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE;QAC5B,MAAM,EAAE;YACN,IAAI,EAAE,aAAI,CAAC,WAAW;YACtB,aAAa;YACb,SAAS,EAAE,MAAM,CAAC,EAAE;SACrB;QACD,MAAM,EAAE;YACN,KAAK,EAAE,UAAU;YACjB,SAAS,EAAE,sBAAsB;YACjC,aAAa;YACb,IAAI,EAAE,aAAI,CAAC,WAAW;YACtB,SAAS,EAAE,MAAM,CAAC,EAAE;SACrB;KACF,CAAC,CAAC;IAEH,MAAM,MAAM,CAAC,OAAO,CAAC,MA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ed.ts
Normal file
192
backend/prisma/seed.ts
Normal file
@@ -0,0 +1,192 @@
|
||||
import bcrypt from "bcryptjs";
|
||||
import { PrismaClient, Role, Currency, PaymentProvider } from "@prisma/client";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
const adminEmail = process.env.ADMIN_EMAIL ?? "admin@proxpanel.local";
|
||||
const adminPassword = process.env.ADMIN_PASSWORD ?? "ChangeMe123!";
|
||||
const password_hash = await bcrypt.hash(adminPassword, 12);
|
||||
|
||||
const tenant = await prisma.tenant.upsert({
|
||||
where: { slug: "default-tenant" },
|
||||
update: {},
|
||||
create: {
|
||||
name: "Default Tenant",
|
||||
slug: "default-tenant",
|
||||
owner_email: adminEmail,
|
||||
currency: Currency.NGN,
|
||||
payment_provider: PaymentProvider.PAYSTACK
|
||||
}
|
||||
});
|
||||
|
||||
await prisma.user.upsert({
|
||||
where: { email: adminEmail },
|
||||
update: {
|
||||
role: Role.SUPER_ADMIN,
|
||||
password_hash,
|
||||
tenant_id: tenant.id
|
||||
},
|
||||
create: {
|
||||
email: adminEmail,
|
||||
full_name: "System Administrator",
|
||||
password_hash,
|
||||
role: Role.SUPER_ADMIN,
|
||||
tenant_id: tenant.id
|
||||
}
|
||||
});
|
||||
|
||||
await prisma.setting.upsert({
|
||||
where: { key: "proxmox" },
|
||||
update: {},
|
||||
create: {
|
||||
key: "proxmox",
|
||||
type: "PROXMOX",
|
||||
value: {
|
||||
host: "",
|
||||
port: 8006,
|
||||
username: "root@pam",
|
||||
token_id: "",
|
||||
token_secret: "",
|
||||
verify_ssl: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
await prisma.setting.upsert({
|
||||
where: { key: "payment" },
|
||||
update: {},
|
||||
create: {
|
||||
key: "payment",
|
||||
type: "PAYMENT",
|
||||
value: {
|
||||
default_provider: "paystack",
|
||||
paystack_public: "",
|
||||
paystack_secret: "",
|
||||
flutterwave_public: "",
|
||||
flutterwave_secret: "",
|
||||
flutterwave_webhook_hash: "",
|
||||
callback_url: ""
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
await prisma.setting.upsert({
|
||||
where: { key: "provisioning" },
|
||||
update: {},
|
||||
create: {
|
||||
key: "provisioning",
|
||||
type: "GENERAL",
|
||||
value: {
|
||||
min_vmid: 100
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
await prisma.setting.upsert({
|
||||
where: { key: "backup" },
|
||||
update: {},
|
||||
create: {
|
||||
key: "backup",
|
||||
type: "GENERAL",
|
||||
value: {
|
||||
default_source: "local",
|
||||
default_storage: "local-lvm",
|
||||
max_restore_file_count: 100,
|
||||
pbs_enabled: false,
|
||||
pbs_host: "",
|
||||
pbs_datastore: "",
|
||||
pbs_namespace: "",
|
||||
pbs_verify_ssl: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
await prisma.billingPlan.upsert({
|
||||
where: { slug: "starter" },
|
||||
update: {},
|
||||
create: {
|
||||
name: "Starter",
|
||||
slug: "starter",
|
||||
description: "Entry plan for lightweight VM workloads",
|
||||
price_monthly: 12000,
|
||||
price_hourly: 12000 / 720,
|
||||
currency: Currency.NGN,
|
||||
cpu_cores: 2,
|
||||
ram_mb: 4096,
|
||||
disk_gb: 60,
|
||||
bandwidth_gb: 2000,
|
||||
features: ["basic-support", "daily-backups"]
|
||||
}
|
||||
});
|
||||
|
||||
const ubuntuTemplate = await prisma.appTemplate.upsert({
|
||||
where: { slug: "ubuntu-22-04-golden" },
|
||||
update: {},
|
||||
create: {
|
||||
name: "Ubuntu 22.04 Golden",
|
||||
slug: "ubuntu-22-04-golden",
|
||||
template_type: "KVM_TEMPLATE",
|
||||
virtualization_type: "QEMU",
|
||||
source: "local:vztmpl/ubuntu-22.04-golden.qcow2",
|
||||
description: "Baseline hardened Ubuntu template",
|
||||
metadata: {
|
||||
os_family: "linux",
|
||||
os_version: "22.04"
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const webGroup = await prisma.applicationGroup.upsert({
|
||||
where: { slug: "web-workloads" },
|
||||
update: {},
|
||||
create: {
|
||||
name: "Web Workloads",
|
||||
slug: "web-workloads",
|
||||
description: "HTTP-facing application services"
|
||||
}
|
||||
});
|
||||
|
||||
await prisma.applicationGroupTemplate.upsert({
|
||||
where: {
|
||||
group_id_template_id: {
|
||||
group_id: webGroup.id,
|
||||
template_id: ubuntuTemplate.id
|
||||
}
|
||||
},
|
||||
update: {},
|
||||
create: {
|
||||
group_id: webGroup.id,
|
||||
template_id: ubuntuTemplate.id,
|
||||
priority: 10
|
||||
}
|
||||
});
|
||||
|
||||
await prisma.backupPolicy.upsert({
|
||||
where: {
|
||||
id: "default-tenant-backup-policy"
|
||||
},
|
||||
update: {},
|
||||
create: {
|
||||
id: "default-tenant-backup-policy",
|
||||
tenant_id: tenant.id,
|
||||
max_files: 25,
|
||||
max_total_size_mb: 102400,
|
||||
max_protected_files: 5,
|
||||
allow_file_restore: true,
|
||||
allow_cross_vm_restore: true,
|
||||
allow_pbs_restore: true
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
main()
|
||||
.then(async () => {
|
||||
await prisma.$disconnect();
|
||||
})
|
||||
.catch(async (error) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error("Seed failed:", error);
|
||||
await prisma.$disconnect();
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user