columnsFields method

List<String> columnsFields ()

Implementation

List<String> columnsFields() {
  List<String> columnsFields = [];
  List<String> foreignKeys = [];

  if (this.primaryKeyName != null) {
    this.primaryKey.setName(this.primaryKeyName);
  }

  columnsFields.add(this.primaryKey.build());

  this.columns.forEach((column) {
    columnsFields.add(column.build());

    if (column.foreignKey != null) {
      foreignKeys.add("FOREIGN KEY (${column.name}) REFERENCES " +
          column.foreignKey[0] +
          " (" +
          column.foreignKey[1] +
          ")");
    }
  });

  foreignKeys.forEach((v) => columnsFields.add(v));

  return columnsFields;
}