server: noop in migration when there's nothing to do
This commit is contained in:
parent
897260ce83
commit
ff6acde702
3 changed files with 8 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
Sequel.migration do
|
Sequel.migration do
|
||||||
up do
|
up do
|
||||||
|
next if table_exists?(:projects)
|
||||||
create_table(:projects) do
|
create_table(:projects) do
|
||||||
primary_key :id
|
primary_key :id
|
||||||
String :name, null: false
|
String :name, null: false
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
Sequel.migration do
|
Sequel.migration do
|
||||||
up do
|
up do
|
||||||
|
next if table_exists?(:tasks)
|
||||||
create_table(:tasks) do |t|
|
create_table(:tasks) do |t|
|
||||||
primary_key :id
|
primary_key :id
|
||||||
String :title, null: false
|
String :title, null: false
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
Sequel.migration do
|
Sequel.migration do
|
||||||
|
column_exists = ->(table, column) do
|
||||||
|
schema = Twenty.connection.schema(table)
|
||||||
|
schema.find { |(key,_)| key == column }
|
||||||
|
end
|
||||||
|
|
||||||
up do
|
up do
|
||||||
|
next if column_exists.call(:projects, :color)
|
||||||
default = Twenty::Mixin::Colorable.random_color
|
default = Twenty::Mixin::Colorable.random_color
|
||||||
add_column :projects, :color, :string, null: false, default:
|
add_column :projects, :color, :string, null: false, default:
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue