Opened 10 years ago

Closed 10 years ago

#24550 closed New feature (fixed)

Always add description of migration operation to sqlmigrate output

Reported by: Markus Holtermann Owned by: Markus Holtermann
Component: Migrations Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Especially when debugging the SQL code generated from migration files it can be hard to see where the code of one migration operation ends and where the next one starts. Instead of only including an operation's description when the operation cannot be reduced to SQL code I propose to always output the description:

BEGIN;
--
-- Create model Author
--
CREATE TABLE "testapp_author" ("id" serial NOT NULL PRIMARY KEY);
--
-- Create model Publisher
--
CREATE TABLE "testapp_publisher" ("id" serial NOT NULL PRIMARY KEY, "name" varchar(100) NOT NULL);
--
-- Add field publishers to author
--
CREATE TABLE "testapp_author_publishers" ("id" serial NOT NULL PRIMARY KEY, "author_id" integer NOT NULL, "publisher_id" integer NOT NULL);
ALTER TABLE "testapp_author_publishers" ADD CONSTRAINT "testapp_author_publishe_author_id_ab13cccc_fk_testapp_author_id" FOREIGN KEY ("author_id") REFERENCES "testapp_author" ("id") DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE "testapp_author_publishers" ADD CONSTRAINT "testapp_author_pu_publisher_id_60b8aa93_fk_testapp_publisher_id" FOREIGN KEY ("publisher_id") REFERENCES "testapp_publisher" ("id") DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE "testapp_author_publishers" ADD CONSTRAINT "testapp_author_publishers_author_id_6e6ec2f2_uniq" UNIQUE ("author_id", "publisher_id");
CREATE INDEX "testapp_author_publishers_4f331e2f" ON "testapp_author_publishers" ("author_id");
CREATE INDEX "testapp_author_publishers_2604cbea" ON "testapp_author_publishers" ("publisher_id");

COMMIT;

Change History (3)

comment:1 by Markus Holtermann, 10 years ago

Has patch: set

comment:2 by Tim Graham, 10 years ago

Triage Stage: UnreviewedReady for checkin

comment:3 by Markus Holtermann <info@…>, 10 years ago

Resolution: fixed
Status: newclosed

In c5cc332b:

Fixed #24550 -- Added migration operation description to sqlmigrate output

Thanks Tim Graham for the review.

Note: See TracTickets for help on using tickets.
Back to Top