toPgSql method

String toPgSql({
  1. required String tableName,
})

Implementation

String toPgSql({
  required String tableName,
}) {
  var out = '';
  if (addNullable) {
    out += 'ALTER TABLE "$tableName" ALTER COLUMN "$columnName"'
        ' DROP NOT NULL;\n';
  } else if (removeNullable) {
    out += 'ALTER TABLE "$tableName" ALTER COLUMN "$columnName"'
        ' SET NOT NULL;\n';
  }
  if (changeDefault) {
    if (newDefault == null) {
      out += 'ALTER TABLE "$tableName" ALTER COLUMN "$columnName"'
          ' DROP DEFAULT;\n';
      return out;
    } else {
      out += 'ALTER TABLE "$tableName" ALTER COLUMN "$columnName"'
          ' SET DEFAULT $newDefault;\n';
    }
  }

  return out;
}