<!--
title: Validate migration conflicts
domain: ai-agents
topic: Migrations
language: Python
source: langflow-ai/langflow
updated: 2025-07-24
url: https://awesomereviewers.com/reviewers/langflow-validate-migration-conflicts/
-->

Before applying database migrations, systematically validate existing data and check for potential conflicts with current schema constraints. This prevents migration failures and ensures backward compatibility.

When modifying database schema or constants that affect database state:

1. **Validate existing data** - Check current data integrity and identify potential constraint violations
2. **Check for naming conflicts** - Ensure new constraints don't conflict with existing constraint names  
3. **Plan data transformation** - Create a step-by-step approach for handling existing data
4. **Create migration scripts** - Generate proper migrations for any changes that affect database state

Example approach for constraint modifications:
```python
# 1. Select all, validate all names per user and update db
# 2. Create new table with constraint that does not conflict with existing constraint  
# 3. Insert into it
# 4. Delete old table
```

This systematic validation prevents issues like foreign key conflicts during table recreation and ensures that changes to constants (like `DEFAULT_FOLDER_NAME`) don't break existing database functions that depend on those values.
