Schema migrations don't create indexes
See original GitHub issueIf 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:
- Created 7 years ago
- Comments:5 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
@coleifer Yes sorry I removed my comment without updating.
database.create_tables([])
do create both table and indexes butdatabase.create_table
does not.