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

fix: migration generator indexes #625

Merged
merged 6 commits into from
Jan 16, 2017

Conversation

nickschot
Copy link
Contributor

A single index was created over id, created_at and updated_at in the default generator for migrations. This also gave problems with mysql (index too long).

@nickschot
Copy link
Contributor Author

Will probably need to modify the migrations of the example applications too. But I'll do that tomorrow.

@codecov-io
Copy link

codecov-io commented Jan 13, 2017

Current coverage is 91.92% (diff: 100%)

Merging #625 into master will not change coverage

@@             master       #625   diff @@
==========================================
  Files           179        179          
  Lines          1981       1981          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits           1821       1821          
  Misses          160        160          
  Partials          0          0          

Powered by Codecov. Last update 93aa5c4...7b9a393

@nickschot
Copy link
Contributor Author

Ugh, this is still wrong. Only way to do it is to set the indexes separately.

Copy link
Contributor

@zacharygolba zacharygolba left a comment

Choose a reason for hiding this comment

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

So I've been thinking about this and I think we're better off adding timestamp indexes individually.

table.timestamps();
table.index('created_at');
table.index('updated_at');

Also, we can remove the additional index on id as it should already be covered as the primary key.

@@ -58,11 +58,11 @@ export default (name: string, attrs: Array<string> | string): string => {
${body}
table.timestamps();

table.index([
table.index(
'id',
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we have to create an additional index for id as it will be the primary key.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed. That is covered. I noticed the need for separate indexes too in the comment before this. Knex has no API to add multiple indexes at once. I'll try to work on this a bit later tonight.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 Sounds good.

Don't generate index for id (covered by PRIMARY already)
@zacharygolba
Copy link
Contributor

👏 This looks good @nickschot. One last thing though. Can you update the migrations in the examples as well as the test-app?

@nickschot nickschot changed the title [WIP] Fix migration generator Fix migration generator Jan 15, 2017
@nickschot nickschot changed the title Fix migration generator Fix migration generator indexes Jan 15, 2017
@nickschot nickschot changed the title Fix migration generator indexes fix: migration generator indexes Jan 15, 2017
@zacharygolba zacharygolba merged commit ebbcf57 into postlight:master Jan 16, 2017
@nickschot nickschot deleted the fix-migration-generator branch January 16, 2017 16:31
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.

3 participants