question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Schema migrations don't create indexes

See original GitHub issue

If you’re doing a migration and add a column with index=True or unique=True it doesn’t automatically create an index. Even trying to perform a migrator.add_index() in the same migrate() block fails.

I’m doing this with the Postgres backend.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
coleifercommented, Feb 27, 2017

Or, oddly, database.create_tables([Model]). The database.create_table method will only create the table, though, whereas create_tables() creates both tables and indexes.

0reactions
gregtapcommented, Feb 27, 2017

@coleifer Yes sorry I removed my comment without updating.

database.create_tables([]) do create both table and indexes but database.create_table does not.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding Indexes with EF Migrations | Passion for Coding
It is tempting to add a SQL command to create the index directly into the Seed function, but it is the wrong place...
Read more >
Why is Entity Framework losing my indexes? - Stack Overflow
Use Automated Migrations/Create scenarios and just call SQL Command direct afterwards to add indexes from code.
Read more >
Migrations: When to use index()? - Laracasts
Should I addindex() for every field? Or just use it on foreign keys? Or? For example, here's one migration: public function up() {...
Read more >
Don't add database index if it already exists in Rails
Rails supports conditionally creating indexes based on whether they exist or not, without raising any error.
Read more >
Database: Migrations - The PHP Framework For Web Artisans
Laravel will use the name of the migration to attempt to guess the name of the table and whether or not the migration...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found