github.com/astaxie/beego@v1.12.3/migration/doc.go (about)

     1  // Package migration enables you to generate migrations back and forth. It generates both migrations.
     2  //
     3  // //Creates a table
     4  // m.CreateTable("tablename","InnoDB","utf8");
     5  //
     6  // //Alter a table
     7  // m.AlterTable("tablename")
     8  //
     9  // Standard Column Methods
    10  // * SetDataType
    11  // * SetNullable
    12  // * SetDefault
    13  // * SetUnsigned (use only on integer types unless produces error)
    14  //
    15  // //Sets a primary column, multiple calls allowed, standard column methods available
    16  // m.PriCol("id").SetAuto(true).SetNullable(false).SetDataType("INT(10)").SetUnsigned(true)
    17  //
    18  // //UniCol Can be used multiple times, allows standard Column methods. Use same "index" string to add to same index
    19  // m.UniCol("index","column")
    20  //
    21  // //Standard Column Initialisation, can call .Remove() after NewCol("") on alter to remove
    22  // m.NewCol("name").SetDataType("VARCHAR(255) COLLATE utf8_unicode_ci").SetNullable(false)
    23  // m.NewCol("value").SetDataType("DOUBLE(8,2)").SetNullable(false)
    24  //
    25  // //Rename Columns , only use with Alter table, doesn't works with Create, prefix standard column methods with "Old" to
    26  // //create a true reversible migration eg: SetOldDataType("DOUBLE(12,3)")
    27  // m.RenameColumn("from","to")...
    28  //
    29  // //Foreign Columns, single columns are only supported, SetOnDelete & SetOnUpdate are available, call appropriately.
    30  // //Supports standard column methods, automatic reverse.
    31  // m.ForeignCol("local_col","foreign_col","foreign_table")
    32  package migration