From 10f7e0d11e67941f5035921d64664d73c6620274 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 4 Aug 2025 16:36:00 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Add=20missing=20model=20fields?= =?UTF-8?q?=20and=20fake=20migration=20for=20Railway=20schema=20sync?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Critical Model/Database Sync Fix **Problem**: Railway database has access_url_name/display_url_name columns but Django model didn't define them. **Solution**: ✅ Add missing fields to Agent model with proper Django field definitions ✅ Create fake migration to sync with existing Railway database schema ✅ Avoid DuplicateColumn errors on Railway deployment ## Changes Made **Agent Model** (): - Added - Added **Migration** (): - Fake migration that does nothing (columns already exist on Railway) - Marks migration as applied without attempting to create existing columns ## Error Fixed ❌ Was: Invalid field name(s) for model Agent: 'access_url_name', 'display_url_name' ✅ Now: Model defines fields that match existing Railway database columns ## Result - Django model matches Railway PostgreSQL schema - Agent creation commands will work (fields are now valid) - populate_agents will succeed and create all 5 agents - Railway marketplace will finally show agents 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- agents/migrations/0005_auto_20250804_1105.py | 23 ++++++++++++++++++++ agents/models.py | 2 ++ 2 files changed, 25 insertions(+) create mode 100644 agents/migrations/0005_auto_20250804_1105.py diff --git a/agents/migrations/0005_auto_20250804_1105.py b/agents/migrations/0005_auto_20250804_1105.py new file mode 100644 index 0000000..2452eaa --- /dev/null +++ b/agents/migrations/0005_auto_20250804_1105.py @@ -0,0 +1,23 @@ +# Generated by Django 5.2.4 on 2025-08-04 11:05 + +from django.db import migrations + + +def fake_migration(apps, schema_editor): + """ + Fake migration - Railway database already has access_url_name and display_url_name columns + but Django model didn't have them defined. Now model has fields, so we just need to + mark this migration as applied without doing anything. + """ + pass + + +class Migration(migrations.Migration): + + dependencies = [ + ("agents", "0004_add_message_limit"), + ] + + operations = [ + migrations.RunPython(fake_migration, fake_migration), + ] diff --git a/agents/models.py b/agents/models.py index 8041e8d..15332aa 100644 --- a/agents/models.py +++ b/agents/models.py @@ -33,6 +33,8 @@ class Agent(models.Model): form_schema = models.JSONField(help_text="JSON schema for agent input form", null=True, blank=True) webhook_url = models.URLField(help_text="n8n webhook URL for execution") message_limit = models.IntegerField(default=50, help_text="Maximum messages per chat session (for chat agents)") + access_url_name = models.CharField(max_length=100, blank=True, default='', help_text="URL name for direct access agents") + display_url_name = models.CharField(max_length=100, blank=True, default='', help_text="URL name for agent display page") is_active = models.BooleanField(default=True) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True)