summaryrefslogtreecommitdiffstats
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20180501132547_add_author_id_to_time_entries.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/db/migrate/20180501132547_add_author_id_to_time_entries.rb b/db/migrate/20180501132547_add_author_id_to_time_entries.rb
new file mode 100644
index 000000000..3d79bf210
--- /dev/null
+++ b/db/migrate/20180501132547_add_author_id_to_time_entries.rb
@@ -0,0 +1,11 @@
+class AddAuthorIdToTimeEntries < ActiveRecord::Migration[5.1]
+ def up
+ add_column :time_entries, :author_id, :integer, :default => nil, :after => :project_id
+ # Copy existing user_id to author_id
+ TimeEntry.update_all('author_id = user_id')
+ end
+
+ def down
+ remove_column :time_entries, :author_id
+ end
+end