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

[WIP] Feat: move to cloud #765

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

[WIP] Feat: move to cloud #765

wants to merge 17 commits into from

Conversation

MrPunyapal
Copy link
Collaborator

No description provided.

$table->rawIndex('name collate nocase', 'name_collate_nocase');
}else{
// mysql
$table->index('name', 'name_case_insensitive', 'BTREE'); // not working
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@steven-fox can you help here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MrPunyapal Hey man. Here's my understanding:

In mysql, collation is controlled on a per-column basis. Therefore, if the collation on the name column of our hashtags table is case insensitive (for example, a collation of utf8mb4_unicode_ci [that _ci is "case-insensitive" instead of _cs for "case-sensitive"]), then you should only need to specify a standard index on the column and you'll be good to go. The custom index was needed for sqlite to force an index that isn't case sensitive.

Try doing a normal $table->index('name'); and then run the tests (or manually check) with a mysql db.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already tried that

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry - I had to re-read the error you sent me of the failing test again. Based on that, it looks like the ACTUAL problem is that a unique constraint violation is occurring when attempting to insert records of foo and Foo, which makes sense, as the column probably has a case insensitive collation so we'd need to manually specify a case sensitive unique index.

Here's what I'd do:

  • Use a case insensitive column definition for hashtags.name (probably the default). Something like utfmb4_0900_ai_ci would be a good choice. Again, probably doesn't have to be specified manually as it's likely the default across the database, but would check for the production db to be sure.
  • Apply a normal index on the name column (so the index will be case insensitive) for our hashtag lookups. Mainly used in \App\Services\Autocomplete\Types\Hashtags and \App\Queries\Feeds\RecentQuestionsFeed.
  • Apply a case sensitive unique index on the name column. I don't think there are Blueprint helpers for this in Laravel. You may have to do DB::raw(CREATE UNIQUE INDEX hashtags_name_unique ON hashtags (name COLLATE utf8mb4_bin);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants