about summary refs log tree commit diff
path: root/db/migrate
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2018-08-12 18:16:26 +0200
committerGitHub <noreply@github.com>2018-08-12 18:16:26 +0200
commit39e361a56d849a027ed12df69122a369bc6ff39d (patch)
treecf178ca2ebfda1c101bba438b42e472926647067 /db/migrate
parent2aeeffc3ec421111f751cab61a15642cbddd9f0d (diff)
Expect relays to answer with accept/reject (#8179)
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20180812123222_change_relays_enabled.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/db/migrate/20180812123222_change_relays_enabled.rb b/db/migrate/20180812123222_change_relays_enabled.rb
new file mode 100644
index 000000000..c4fd8179b
--- /dev/null
+++ b/db/migrate/20180812123222_change_relays_enabled.rb
@@ -0,0 +1,19 @@
+class ChangeRelaysEnabled < ActiveRecord::Migration[5.2]
+  def up
+    # The relays table is supposed to be very small,
+    # single-digit number of rows, so this should be fine
+    safety_assured do
+      add_column :relays, :state, :integer, default: 0, null: false
+
+      # At the time of this migration, no relays reject anyone, so if
+      # there are enabled ones, they are accepted
+      execute 'UPDATE relays SET state = 2 WHERE enabled = true'
+      remove_column :relays, :enabled
+    end
+  end
+
+  def down
+    remove_column :relays, :state
+    add_column :relays, :enabled, :boolean, default: false, null: false
+  end
+end