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

Schema Migration Overriding exist Indexes #9112

Open
badboy-tian opened this issue Apr 30, 2024 · 15 comments
Open

Schema Migration Overriding exist Indexes #9112

badboy-tian opened this issue Apr 30, 2024 · 15 comments
Labels
bounty:$20 Bounty applies for fixing this issue (Parse Bounty Program) type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@badboy-tian
Copy link

New Issue Checklist

Issue Description

Schema Migration Overriding exist Indexes

Steps to reproduce

1.create some index in mongodb tools
image
2.define ExportTool class in schema

export const ExportTotal = {
    className: "ExportTotal",
    fields: {
        myid: {type: "Number", defaultValue: 0},
        money: {type: "Number", defaultValue: 0},
        type: {type: "String"},
        user: {type: "Pointer", targetClass: "_User"},
    },
    
    classLevelPermissions: {
        find: {},
        count: {},
        get: {},
        update: {},
        create: {},
        delete: {},
        protectedFields: {},
    },
}

3.config the parse-server

schema: {
        definitions:[ExportTool],
        lockSchemas: false,
        strict: true,
        recreateModifiedFields: true,
        deleteExtraFields: true,
    },

image

Actual Outcome

when parse server running, the exist index has dispear

Expected Outcome

when parse server running, the exist index shoud not dispear

Environment

Server

  • Parse Server version: 7.0.0
  • Operating system: macos
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): local

Database

  • System (MongoDB or Postgres): mongodb
  • Database version: 7.0.8
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): local

Client

  • SDK (iOS, Android, JavaScript, PHP, Unity, etc): no
  • SDK version: no

Logs

info: 11:34:54 -> Node app is running on port: 1337
[TS] info: Running Migrations
[TS] info: Running Migrations Completed

Copy link

Thanks for opening this issue!

  • 🚀 You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.

@mtrezza
Copy link
Member

mtrezza commented Apr 30, 2024

What is the expected behavior according to the defined schema docs? I couldn't any specific mention of this in the docs.

@mtrezza mtrezza added the type:bug Impaired feature or lacking behavior that is likely assumed label Apr 30, 2024
@badboy-tian
Copy link
Author

@mtrezza I hope the "Schema Migration" doesn't overwrite the Index I created with the mongodb tool!

@badboy-tian
Copy link
Author

@mtrezza because the follow can not create unique index

indexes: {
    tagsIndex: { 
                          tags: 1 ,
                          // unique: true ?
                      } 

so i must create unique index in mongodb shell or mongodb tool.
then i run the "the defined schema" in parse-server, when log

info: 11:34:54 -> Node app is running on port: 1337
[TS] info: Running Migrations
[TS] info: Running Migrations Completed

the unique index created by mongodb shell was dispear.... Overriding ?

@mtrezza
Copy link
Member

mtrezza commented May 1, 2024

Some behavior is not explicitly described for indexes in the docs. For example if you set strict: true, then I would assume that indexes that aren't defined in the schema would be deleted, just like classes, fields, CPLs. In see in your case you have also set this option.

Did you take a look at the code to investigate what the current behavior is regarding indexes, so we can update the docs with the status quo? Then we can think about what we want to change.

@badboy-tian
Copy link
Author

@mtrezza yes, when set strict: false the exist indexes was not overrided !

but because the index define in the define schema can not support create unique index, so we have to create unique index in mongodb tools. very inconvenient.

is there any way to supprot this?

indexes: {
   tag_index: {
          tag: 1, 
          unique: true, 
          background: true,
          sparse: true
    }

}

thank you

@rgunindi
Copy link

rgunindi commented May 1, 2024

Some behavior is not explicitly described for indexes in the docs. For example if you set strict: true, then I would assume that indexes that aren't defined in the schema would be deleted, just like classes, fields, CPLs. In see in your case you have also set this option.

Did you take a look at the code to investigate what the current behavior is regarding indexes, so we can update the docs with the status quo? Then we can think about what we want to change.

And also for strict true or false whatever result the same[also with another options]. I debugged with changing options but the result will be the same: overrides indexes. @mtrezza

@mtrezza
Copy link
Member

mtrezza commented May 1, 2024

when set strict: false the exist indexes was not overrided !

for strict true or false whatever result the same ... overrides indexes

Which one is true?

@badboy-tian
Copy link
Author

perhaps there is a unknow bug. i set strict: false, the index also overrided , i do not know why

@badboy-tian
Copy link
Author

screen_record.mp4

@mtrezza @rgunindi please see the screen record, set strict: false, also override the exist index

@badboy-tian
Copy link
Author

@mtrezza @rgunindi

@rgunindi
Copy link

rgunindi commented May 3, 2024

screen_record.mp4

@mtrezza @rgunindi please see the screen record, set strict: false, also override the exist index

Yes ı said, for strict true or false whatever result the same ... overrides indexes

@badboy-tian
Copy link
Author

@rgunindi yes, you are right

@badboy-tian
Copy link
Author

any update ?

@rgunindi
Copy link

Don't expect early action 😁 Will take so long time

@mtrezza mtrezza added the bounty:$20 Bounty applies for fixing this issue (Parse Bounty Program) label May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty:$20 Bounty applies for fixing this issue (Parse Bounty Program) type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

No branches or pull requests

3 participants