status-go icon indicating copy to clipboard operation
status-go copied to clipboard

drop incorrect index on user_messages_edits and create index on user_messages_deletes

Open michaelsbradleyjr opened this issue 4 years ago • 9 comments
trafficstars

In protocol/migrations/sqlite/1625762506_add_deleted_messages.up.sql an index is created on user_messages_edits but it should instead be created on user_messages_deletes.

Drop the incorrect index and create the correct one.


I installed go-bindata via make gen-install, and I ran go generate within the protocol/migrations/sqlite directory.

Let me know if I missed a step or did something incorrectly and I'll fix it ASAP.

michaelsbradleyjr avatar Sep 08 '21 19:09 michaelsbradleyjr

Pull Request Checklist

  • [ ] Have you updated the documentation, if impacted (e.g. docs.status.im)?
  • [ ] Have you tested changes with mobile or desktop version?

status-github-bot[bot] avatar Sep 08 '21 19:09 status-github-bot[bot]

Jenkins Builds

Click to see older builds (3)
:grey_question: Commit :hash: Finished (UTC) Duration Platform Result
:heavy_check_mark: 563309ff #1 2021-09-08 20:01:21 ~2 min linux :package:zip
:heavy_check_mark: 563309ff #1 2021-09-08 20:02:07 ~3 min ios :package:zip
:heavy_check_mark: 563309ff #1 2021-09-08 20:05:40 ~6 min android :package:aar
:grey_question: Commit :hash: Finished (UTC) Duration Platform Result
:heavy_check_mark: cafb9832 #2 2021-10-04 06:22:16 ~3 min linux :package:zip
:heavy_check_mark: cafb9832 #2 2021-10-04 06:22:44 ~4 min ios :package:zip
:heavy_check_mark: cafb9832 #2 2021-10-04 06:25:05 ~6 min android :package:aar
:heavy_check_mark: 006150c8 #3 2021-10-05 18:58:16 ~2 min ios :package:zip
:heavy_check_mark: 006150c8 #3 2021-10-05 18:58:25 ~2 min linux :package:zip
:heavy_check_mark: 006150c8 #3 2021-10-05 19:02:10 ~6 min android :package:aar

status-im-auto avatar Sep 08 '21 20:09 status-im-auto

Hey @michaelsbradleyjr the filename of your migration should have the *.up.sql suffix otherwise it won't be picked up by the migrator.

There are also a helpful make commands that will prefix with a unix timestamp and the correct suffixes for you,

  • make migration D=<MIGRATION NAME>
    • Outputs to appdatabase/migrations/sql/<MIGRATION FILE>
  • make migration-protocol D=<MIGRATION NAME>
    • Outputs to protocol/migrations/sqlite/<MIGRATION FILE>

Samyoul avatar Sep 10 '21 12:09 Samyoul

Sorry to leave this hanging, I didn't notice the email with @Samyoul's reply and just now thought to check back on this PR.

@Samyoul I'm happy to add the .up.sql suffix. When I created the file at the time, I saw there was already a file named 1628280060_create-usermessages-index.sql (lacking the suffix) and it was picked up by the migrator, so I named mine similarly since it likewise only deals with an index.

Should I rename both files so they end with .up.sql or only mine?

michaelsbradleyjr avatar Sep 20 '21 16:09 michaelsbradleyjr

Hey @michaelsbradleyjr that's interesting. Are you able to see that the new indexes are created? I can see that make generate picks up the migration file to create a comm, but without the .up.sql suffix the migrator can't know if a migration is up or down.

I've checked this migration and the one you mention directly in the db, it isn't being picked up.

Screenshot 2021-09-30 at 16 16 16 Screenshot 2021-09-30 at 16 18 00

Samyoul avatar Sep 30 '21 15:09 Samyoul

Are you able to see that the new indexes are created?

No, actually! Good catch.

I had conflated seeing the incorrect index added in 1625762506_add_deleted_messages.up.sql (in a command-line dump of the schema) with the index added in 1628280060_create-usermessages-index.sql.

So I should change the name of 1628280060_create-usermessages-index.sql to 1628280060_create-usermessages-index.up.sql and 1631129360_fix-deletedmessages-index.sql to 1631129360_fix-deletedmessages-index.up.sql, and that's it?

michaelsbradleyjr avatar Sep 30 '21 18:09 michaelsbradleyjr

So I should change the name of 1628280060_create-usermessages-index.sql to 1628280060_create-usermessages-index.up.sql and 1631129360_fix-deletedmessages-index.sql to 1631129360_fix-deletedmessages-index.up.sql, and that's it?

Yes, that should be enough for the migrator to pick up the new migrations

Samyoul avatar Oct 01 '21 08:10 Samyoul

Done!

michaelsbradleyjr avatar Oct 04 '21 06:10 michaelsbradleyjr

@michaelsbradleyjr is PR still relevant?

churik avatar May 12 '22 09:05 churik