U4-10881 - Add Check Syntax Builder to MigrationBase class

Created by Jamie Pollock 23 Jan 2018, 15:42:07 Updated by Jamie Pollock 13 Mar 2018, 15:39:45

Ideally looking to add on top of the current MigrationBase Fluent API the means to check if various database objects already exists before carrying out a migration.

This would probably take the form of something a bit like this:

Check.Table("tableName").Exists(); Check.Tables("tableName", "tableName2").Exists();

Check.Table("tableName").Index("indexName").Exists();

Check.Table("tableName").Column("columnName").Exists(); Check.Table("tableName").Columns("columnName", "columnName2").Exists();

Check.Table("tableName").Column("columnName").IsType("dbType"); //Possibly add a non-string overload Check.Table("tableName").Column("columnName").HasIndex("indexName");

Expected usage would something like this:

public override void Up() { if(Check.Table("people").Column("dateOfBirth").Exists()) { //Log we're skipping this } else { Alter.Table("people").AddColumn("dateOfBirth").AsDateTime().Nullable(); } }

Comments

Jamie Pollock 17 Feb 2018, 14:20:38

@nul800sebastiaan Hey Sebastiaan! I've just submitted a PR over on github for this:

https://github.com/umbraco/Umbraco-CMS/pull/2451

It's fairly extensive and covers all areas you'd expect from the Migrations fluent syntax:

  • Table
  • Table Columns
  • Index
  • ForeignKey
  • Constraint

I'd like to assist with documentation do you have any guidance about how I can best contribute? The other Migrations builders (Create, Delete, Alter, etc) are lacking documentation at the moment so I'm not sure where I should start.

Perhaps I could start with a docx file which highlights all possibly combinations of fluent syntax for this new feature?

Happy to help however I can get this included in the Core :)


Jamie Pollock 13 Mar 2018, 15:39:45

@sebastiaan sorry, I must have used the wrong mention! I'm really out of touch with the issue tracker. :)


Priority: Normal

Type: Feature (request)

State: Review

Assignee:

Difficulty: Normal

Category: Architecture

Backwards Compatible: True

Fix Submitted: Pull request

Affected versions:

Due in version:

Sprint:

Story Points:

Cycle: