Merge branch '8784-dir-listings'
[arvados.git] / services / api / db / migrate / 20160808151559_create_workflows.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 class CreateWorkflows < ActiveRecord::Migration
6   def up
7     create_table :workflows do |t|
8       t.string :uuid
9       t.string :owner_uuid
10       t.datetime :created_at
11       t.datetime :modified_at
12       t.string :modified_by_client_uuid
13       t.string :modified_by_user_uuid
14       t.string :name
15       t.text :description
16       t.text :workflow
17
18       t.timestamps
19     end
20
21     add_index :workflows, :uuid, :unique => true
22     add_index :workflows, :owner_uuid
23     add_index :workflows, ["uuid", "owner_uuid", "modified_by_client_uuid", "modified_by_user_uuid", "name"], name: 'workflows_search_idx'
24     execute "CREATE INDEX workflows_full_text_search_idx ON workflows USING gin(#{Workflow.full_text_tsvector});"
25   end
26
27   def down
28     remove_index :workflows, :name => 'workflows_full_text_search_idx'
29     remove_index :workflows, :name => 'workflows_search_idx'
30     remove_index :workflows, :owner_uuid
31     remove_index :workflows, :uuid
32     drop_table :workflows
33   end
34 end