Comments (4)
Hey! This migration fails because of a data dependent change. You are adding a foreign key on data where that does not satisfy this constraint.
In your case the image table seems to hold a row with an recipe id that does not exist.
There are ways to fix this, e.g. by removing conflicting rows before applying the change.
I suggest you have a look at the atlas migrat lint
command.
from atlas.
Ok but this isn't fixed.
I know what's happening, but this can still happen again anytime a field is added to the foreign key edge.
Before there was just an edge that went from recipe to image O2M.
Now the image has a named field "recipe_id", so the table had its field changed from recipe_image to recipe_id.
But the migration tool is unable to create a proper migration.
This is a bug.
Atlas is supposed to be a tool that keeps watch and helps with migrations, tracks changes and creates the SQL so that you can apply all the migrations in sequence.
In this case it doesn't do the job, it fails to do the job, creates a non-working migration.
from atlas.
Hello @idc77, you can use the StorageKey option to keep the old column, so any migration engine (ent’s or atlas) won’t try to drop and re-create the column for that field. Please let me know if it helps.
https://entgo.io/docs/schema-fields/#storage-key
from atlas.
I just see now that it drops and re-creates the column, sorry missed that before. It's not really possible to determine if for a change made in the desired schema if it's a rename (like in your case) or a drop+add with equal types.
This is one of the reasons why there is atlas migrate lint
. It would have told you that dropping a column is dangerous and most likely not intentional. Also, you can edit a generated migration and change the drop+add to a column rename. Or just use the StorageKey
option as @giautm mentioned to keep the database column name.
However, we are actively working on solutions for these type of problems.
from atlas.
Related Issues (20)
- suppor triggers migration in PostgresSQL HOT 6
- `atlas apply`, ignoring postgres extensions *already* present in the database
- Custom baseline sql script HOT 6
- Support for installation using go install HOT 5
- Add ability to define schema in Nickel
- Support Azure Sql Database and using Azure AD or Workload Identity Authentication HOT 8
- Error: role does not exist HOT 1
- Error: cannot diff a database connection with a schema "name_schema" HOT 5
- Support for StarRocks
- How to create schema object in MSSQL database? HOT 22
- The creation of PostgreSQL collation parameters is ignored
- Can't push migrations to Atlas Cloud HOT 5
- CREATE SEQUENCE for MSSQL database fails HOT 3
- Issue excluding objects from `schema diff` HOT 4
- Atlas-operator helm chart doesn't support customization of labels HOT 2
- [Bug] Incorrect command argument in `Introduction to Atlas Migrations` documentation HOT 4
- terraform migration: "atlas_schema_revisions" table created in "public" schema HOT 13
- use multi tenant environment got error `Error: multiple envs found for` HOT 2
- Timeout on dev database on ipv6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from atlas.