mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-04-04 23:07:56 +10:00
use full dotted paths for all archivebox imports, add migrations and more fixes
This commit is contained in:
@@ -7,8 +7,13 @@ class MachineConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
|
||||
name = 'archivebox.machine'
|
||||
label = 'machine' # Explicit label for migrations
|
||||
verbose_name = 'Machine Info'
|
||||
|
||||
def ready(self):
|
||||
"""Import models to register state machines with the registry"""
|
||||
from archivebox.machine import models # noqa: F401
|
||||
|
||||
|
||||
def register_admin(admin_site):
|
||||
from archivebox.machine.admin import register_admin
|
||||
|
||||
@@ -85,6 +85,12 @@ class Migration(migrations.Migration):
|
||||
('version', models.CharField(blank=True, default=None, max_length=32)),
|
||||
('sha256', models.CharField(blank=True, default=None, max_length=64)),
|
||||
('machine', models.ForeignKey(blank=True, default=None, on_delete=django.db.models.deletion.CASCADE, to='machine.machine')),
|
||||
# Fields added in migration 0005 (included here for fresh installs)
|
||||
('binproviders', models.CharField(blank=True, default='env', max_length=127)),
|
||||
('output_dir', models.CharField(blank=True, default='', max_length=255)),
|
||||
('overrides', models.JSONField(blank=True, default=dict)),
|
||||
('retry_at', models.DateTimeField(blank=True, db_index=True, default=django.utils.timezone.now, null=True)),
|
||||
('status', models.CharField(choices=[('queued', 'Queued'), ('started', 'Started'), ('succeeded', 'Succeeded'), ('failed', 'Failed')], db_index=True, default='queued', max_length=16)),
|
||||
# dependency FK removed - Dependency model deleted
|
||||
],
|
||||
options={
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
# Generated by Django 6.0 on 2025-12-29 06:45
|
||||
|
||||
import django.db.models.deletion
|
||||
import django.utils.timezone
|
||||
from archivebox.uuid_compat import uuid7
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('machine', '0004_drop_dependency_table'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
# Update Django's state only - database already has correct schema
|
||||
migrations.SeparateDatabaseAndState(
|
||||
state_operations=[
|
||||
migrations.AddField(
|
||||
model_name='binary',
|
||||
name='binproviders',
|
||||
field=models.CharField(blank=True, default='env', help_text='Comma-separated list of allowed providers: apt,brew,pip,npm,env', max_length=127),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='binary',
|
||||
name='output_dir',
|
||||
field=models.CharField(blank=True, default='', help_text='Directory where installation hook logs are stored', max_length=255),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='binary',
|
||||
name='overrides',
|
||||
field=models.JSONField(blank=True, default=dict, help_text="Provider-specific overrides: {'apt': {'packages': ['pkg']}, ...}"),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='binary',
|
||||
name='retry_at',
|
||||
field=models.DateTimeField(blank=True, db_index=True, default=django.utils.timezone.now, help_text='When to retry this binary installation', null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='binary',
|
||||
name='status',
|
||||
field=models.CharField(choices=[('queued', 'Queued'), ('started', 'Started'), ('succeeded', 'Succeeded'), ('failed', 'Failed')], db_index=True, default='queued', max_length=16),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='binary',
|
||||
name='abspath',
|
||||
field=models.CharField(blank=True, default='', max_length=255),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='binary',
|
||||
name='binprovider',
|
||||
field=models.CharField(blank=True, default='', help_text='Provider that successfully installed this binary', max_length=31),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='binary',
|
||||
name='id',
|
||||
field=models.UUIDField(default=uuid7, editable=False, primary_key=True, serialize=False, unique=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='binary',
|
||||
name='machine',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='machine.machine'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='binary',
|
||||
name='name',
|
||||
field=models.CharField(blank=True, db_index=True, default='', max_length=63),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='binary',
|
||||
name='sha256',
|
||||
field=models.CharField(blank=True, default='', max_length=64),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='binary',
|
||||
name='version',
|
||||
field=models.CharField(blank=True, default='', max_length=32),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='machine',
|
||||
name='config',
|
||||
field=models.JSONField(blank=True, default=dict, help_text='Machine-specific config overrides (e.g., resolved binary paths like WGET_BINARY)', null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='machine',
|
||||
name='id',
|
||||
field=models.UUIDField(default=uuid7, editable=False, primary_key=True, serialize=False, unique=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='machine',
|
||||
name='stats',
|
||||
field=models.JSONField(blank=True, default=dict, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='networkinterface',
|
||||
name='id',
|
||||
field=models.UUIDField(default=uuid7, editable=False, primary_key=True, serialize=False, unique=True),
|
||||
),
|
||||
],
|
||||
database_operations=[
|
||||
# No database changes - schema already correct from previous migrations
|
||||
],
|
||||
),
|
||||
]
|
||||
@@ -44,8 +44,8 @@ class Machine(ModelWithHealthStats):
|
||||
os_platform = models.CharField(max_length=63, default=None, null=False)
|
||||
os_release = models.CharField(max_length=63, default=None, null=False)
|
||||
os_kernel = models.CharField(max_length=255, default=None, null=False)
|
||||
stats = models.JSONField(default=dict, null=False)
|
||||
config = models.JSONField(default=dict, null=False, blank=True,
|
||||
stats = models.JSONField(default=dict, null=True, blank=True)
|
||||
config = models.JSONField(default=dict, null=True, blank=True,
|
||||
help_text="Machine-specific config overrides (e.g., resolved binary paths like WGET_BINARY)")
|
||||
num_uses_failed = models.PositiveIntegerField(default=0)
|
||||
num_uses_succeeded = models.PositiveIntegerField(default=0)
|
||||
@@ -213,7 +213,7 @@ class Binary(ModelWithHealthStats):
|
||||
num_uses_failed = models.PositiveIntegerField(default=0)
|
||||
num_uses_succeeded = models.PositiveIntegerField(default=0)
|
||||
|
||||
state_machine_name: str = 'machine.models.BinaryMachine'
|
||||
state_machine_name: str = 'archivebox.machine.models.BinaryMachine'
|
||||
|
||||
objects: BinaryManager = BinaryManager()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user