Migration builder: table-level indexes, column modifiers, drop/rename/change, and fixes - #345
Merged
Merged
Conversation
…/change, and fixes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Checklist
Description
Summary
Brings the Doppar migration builder (
Phaseolies\Database\Migration) to feature parity with the other major PHP frameworks, and fixes several bugs found along the way.$table->string('title')->index()already worked; what was missing was table-level$table->index()(and everything around it).Bug fixes
Schema::create()sent all statements in oneprepare()call and SQLite runs only the first, so column->index()/->unique()indexes were never created.Schemanow executes statements one by one via the newBlueprint::toStatements()(toSql()still works and joins them).PRIMARY KEYon MySQL/PostgreSQL when->primary()was used on a non-id column.addslashes(), which is invalid on PostgreSQL/SQLite. Now escaped per driver.CREATE TABLE(SQLite cannotALTER TABLE ADD CONSTRAINT).New features
index,unique,primary,fullText,spatialIndexat table level (composite, custom name,->algorithm()); column-level->index('name'),->unique('name'),->fullText(),->spatialIndex().dropColumn,renameColumn,dropIndex,dropUnique,dropFullText,dropSpatialIndex,dropPrimary,dropForeign,renameIndex,dropTimestamps,dropSoftDeletes,dropRememberToken,dropMorphs,dropConstrainedForeignId.->change()to modify existing columns (MySQLMODIFY COLUMN, PostgreSQLALTER COLUMN; SQLite throws a clear error).comment,unsigned,useCurrent,useCurrentOnUpdate,autoIncrement,charset,collation,storedAs/virtualAs,invisible,first,nullable(false).foreignId()->constrained()(table guessed from column name),foreignUuid,foreignUlid, composite keys,->name(),noActionOnDelete/Update.incrementsfamily,ulid,rememberToken,morphs/nullableMorphs/uuidMorphs/ulidMorphs,softDeletesTz,nullableTimestamps, precision argument on temporal columns.engine,charset,collation,comment,temporary.Schema:drop,rename,dropColumns,renameColumn,hasColumn,hasColumns,getColumnListing,hasIndex(facade docblock updated).Behaviour notes / compatibility
idx_{table}_{col},{table}_{col}_unique), so existingdown()migrations keep working. Names over 63 chars are shortened with a hash.Blueprint::softDeletes()now returns theColumnDefinitioninstead ofvoid(accepts an optional column name).Grammar::compileCreateIndex()/compileCreateUnique()gained an optional$nameparameter. Custom grammar subclasses must add it.Database::execute()still splits on;, so a comment containing;would break there (pre-existing, untouched).Docs
docs/content/docs/versions/4.x/migrations.md(docs repo) updated with all of the above. The outdated warning about needingafter()when adding several columns was removed.Checklist