1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-02 17:06:09 +00:00
webvirtcloud/vmbackups/migrations/0001_initial.py
catborise c7d6f90823 feat(vmbackups): the backups app and its records
A new app holds VM backups: a backup target (a storage pool on each
compute that sees it, its UUID kept to refuse a replaced pool), the
backups (kept with the VM's name and UUID when the VM row goes) and their
files. Claim keys for a target and a backup. Nothing uses them yet.

Installs with their own settings.py add "vmbackups" to INSTALLED_APPS.
2026-11-17 07:32:35 +03:00

76 lines
4 KiB
Python

# Generated by Django 5.2.18 on 2026-11-17 04:32
import django.db.models.deletion
import uuid
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
('computes', '0011_maintenance_since'),
('instances', '0016_vm_name_length'),
('operations', '0004_parent'),
]
operations = [
migrations.CreateModel(
name='BackupTarget',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=64, unique=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
],
),
migrations.CreateModel(
name='Backup',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
('vm_uuid', models.CharField(max_length=36)),
('vm_name', models.CharField(max_length=255)),
('compute_name', models.CharField(max_length=255)),
('created_at', models.DateTimeField(auto_now_add=True)),
('finished_at', models.DateTimeField(null=True)),
('state', models.CharField(choices=[('creating', 'creating'), ('ready', 'ready'), ('failed', 'failed'), ('deleting', 'deleting')], default='creating', max_length=16)),
('consistency', models.CharField(blank=True, choices=[('offline', 'offline'), ('frozen', 'frozen'), ('crash', 'crash-consistent')], max_length=16)),
('size', models.BigIntegerField(default=0)),
('manifest', models.JSONField(default=dict)),
('instance', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='backups', to='instances.instance')),
('operation', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='operations.operation')),
('target', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='backups', to='vmbackups.backuptarget')),
],
options={
'ordering': ['-created_at'],
},
),
migrations.CreateModel(
name='BackupFile',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('role', models.CharField(choices=[('disk', 'disk'), ('nvram', 'nvram'), ('domain', 'domain'), ('manifest', 'manifest')], max_length=16)),
('dev', models.CharField(blank=True, max_length=32)),
('volume', models.CharField(max_length=255)),
('format', models.CharField(blank=True, max_length=16)),
('capacity', models.BigIntegerField(default=0)),
('size', models.BigIntegerField(default=0)),
('sha256', models.CharField(blank=True, max_length=64)),
('backup', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='files', to='vmbackups.backup')),
],
),
migrations.CreateModel(
name='BackupTargetPool',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('pool', models.CharField(max_length=128)),
('pool_uuid', models.CharField(max_length=36)),
('compute', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='computes.compute')),
('target', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='pools', to='vmbackups.backuptarget')),
],
options={
'constraints': [models.UniqueConstraint(fields=('target', 'compute'), name='one_pool_per_target_and_compute')],
},
),
]