Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applying snapshot is a destructive behaviour when you have custom migrations #18067

Closed
hgezim opened this issue Apr 5, 2023 · 3 comments · Fixed by #18264
Closed

Applying snapshot is a destructive behaviour when you have custom migrations #18067

hgezim opened this issue Apr 5, 2023 · 3 comments · Fixed by #18264

Comments

@hgezim
Copy link

hgezim commented Apr 5, 2023

Describe the Bug

If you have a custom migration that changes a field type from string (255) to text and it's applied after the snapshot, on container restart, data gets lost as the migration change is reverted.

This follows the guidelines outlined in the docs:

1 npx directus database install
2 npx directus database migrate:latest
3 npx directus schema apply ./path/to/snapshot.yaml
4 mv .custom-migrations/* migrations/
5 npx directus database migrate:latest

To Reproduce

  1. Create a collection called Images
  2. Create a field called description as type string (255 length)
  3. Save the schema and apply it in the order of the docs (above).
  4. Create a custom migration to change description type from string to text
  5. Create new data for description with > 255 length
  6. Restart contianer

Expected:
Snapshot changes not be descrutive.

Actual: snapshot change is destructive and text gets truncated to 255.

Hosting Strategy

Self-Hosted (Docker Image)

@paescuj
Copy link
Member

paescuj commented Apr 5, 2023

Thanks for opening this issue!
I'm afraid the documentation propagates a wrong way here for the reasons I've explained in #11798 (reply in thread).
Not sure why this has been adopted in the documentation, but I'll see that this part gets adjusted accordingly 👍

@paescuj
Copy link
Member

paescuj commented Apr 5, 2023

/linear

@github-actions
Copy link

github-actions bot commented Apr 5, 2023

🤖 Linear issue created! Maintainers can access it here: ENG-878

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants