💥 [DevOps] On Auto Deploy To `stage.ocelot.social` We Have An Error
Created by: Tirokk
💥 DevOps ticket
Reason and possible soluition below !!!
On auto deploy to stage.ocelot.social
we have an error.
Additional Informations
The migration 20220803060819-create_fulltext_indices_and_unique_keys_for_groups.js
node was there.
A look into the database with the following query gives:
neo4j> MATCH (n:Migration) RETURN n;
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| n |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| (:Migration {migratedAt: "2022-10-25T12:45:53.406Z", title: "1613589876420-null_mutation.js", timestamp: 1.666705449183E12}) |
| (:Migration {description: "
This migration adds the clickedCount property to all posts, setting it to 0.
", migratedAt: "2022-10-25T12:45:53.681Z", title: "1614023644903-add-clickedCount-to-posts.js", timestamp: 1.66670544924E12}) |
| (:Migration {description: "
This migration adds the viewedTeaserCount property to all posts, setting it to 0.
", migratedAt: "2022-10-25T12:45:53.69Z", title: "1614177130817-add-viewedTeaserCount-to-posts.js", timestamp: 1.666705449315E12}) |
| (:Migration {description: "This migration adds a Donations node with default settings to the database.", migratedAt: "2022-10-25T12:45:53.696Z", title: "20210506150512-add-donations-node.js", timestamp: 1.666705449364E12}) |
| (:Migration {description: "", migratedAt: "2022-10-25T12:45:53.7Z", title: "20210923140939-add-sendNotificationEmails-property-to-all-users.js", timestamp: 1.666705449457E12}) |
| (:Migration {description: "
We introduced a new node label 'Group' and we need two primary keys 'id' and 'slug' for it.
Additional we like to have fulltext indices the keys 'name', 'slug', 'about', and 'description'.
", migratedAt: "2022-10-25T12:45:53.704Z", title: "20220803060819-create_fulltext_indices_and_unique_keys_for_groups.js"}) |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
But this migration was not removed on:
$ kubectl -n default exec -it $(kubectl -n default get pods | grep ocelot-backend | awk '{ print $1 }') -- /bin/sh -c "yarn prod:migrate down"
Gives:
Anchor-MBP:Ocelot-Social-Deploy-Rebranding wolfgang$ kubectl -n default exec -it $(kubectl -n default get pods | grep ocelot-backend | awk '{ print $1 }') -- /bin/sh -c "yarn prod:migrate down"
yarn run v1.22.5
$ migrate --migrations-dir ./dist/db/migrations --store ./dist/db/migrate/store.js down
down : 20210923140939-add-sendNotificationEmails-property-to-all-users.js
down : 20210506150512-add-donations-node.js
down : 1614177130817-add-viewedTeaserCount-to-posts.js
down : 1614023644903-add-clickedCount-to-posts.js
down : 1613589876420-null_mutation.js
migration : complete
Done in 1.24s.
Database query afterwards:
neo4j> MATCH (n:Migration) RETURN n;
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| n |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| (:Migration {title: "1613589876420-null_mutation.js", migratedAt: "2022-10-25T12:45:53.406Z"}) |
| (:Migration {description: "
This migration adds the clickedCount property to all posts, setting it to 0.
", migratedAt: "2022-10-25T12:45:53.681Z", title: "1614023644903-add-clickedCount-to-posts.js"}) |
| (:Migration {description: "
This migration adds the viewedTeaserCount property to all posts, setting it to 0.
", migratedAt: "2022-10-25T12:45:53.69Z", title: "1614177130817-add-viewedTeaserCount-to-posts.js"}) |
| (:Migration {description: "This migration adds a Donations node with default settings to the database.", migratedAt: "2022-10-25T12:45:53.696Z", title: "20210506150512-add-donations-node.js"}) |
| (:Migration {description: "", migratedAt: "2022-10-25T12:45:53.7Z", title: "20210923140939-add-sendNotificationEmails-property-to-all-users.js"}) |
| (:Migration {description: "
We introduced a new node label 'Group' and we need two primary keys 'id' and 'slug' for it.
Additional we like to have fulltext indices the keys 'name', 'slug', 'about', and 'description'.
", migratedAt: "2022-10-25T12:45:53.704Z", title: "20220803060819-create_fulltext_indices_and_unique_keys_for_groups.js"}) |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
6 rows available after 5 ms, consumed after another 1 ms
This shouldn't be the case. Or?
If I remove INDEX ON NODE:Group(name, slug, about, description)
manually by:
$ CALL db.index.fulltext.drop("group_fulltext_search");
Then up
works !!!
Reason And Possible Solution
On automatic deployment the database gets cleaned and that deletes the migration nodes. But it dosn't deletes the indexes. If the migrations runs again the group intexes getting created again and that generates the error.
So the solkution can be
- not to delete the migration nodes or
- always drop the indexes or
- always drop the group index before creation if it exists or
- …