summaryrefslogtreecommitdiff
path: root/db/migrate/20171013094327_create_new_clusters_architectures.rb
blob: dabb3e25e4802c287faafd34105a903ac55364f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
class CreateNewClustersArchitectures < ActiveRecord::Migration
  DOWNTIME = false

  def change
    create_table :clusters do |t|
      t.references :user, index: true, foreign_key: { on_delete: :nullify }

      t.integer :provider_type
      t.integer :platform_type

      t.datetime_with_timezone :created_at, null: false
      t.datetime_with_timezone :updated_at, null: false

      t.boolean :enabled, index: true, default: true

      t.string :name, null: false # If manual, read-write. If gcp, read-only.
    end

    create_table :cluster_projects do |t|
      t.references :project, null: false, index: true, foreign_key: { on_delete: :cascade }
      t.references :cluster, null: false, index: true, foreign_key: { on_delete: :cascade }

      t.datetime_with_timezone :created_at, null: false
      t.datetime_with_timezone :updated_at, null: false
    end

    create_table :cluster_platforms_kubernetes do |t|
      t.references :cluster, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade }

      t.datetime_with_timezone :created_at, null: false
      t.datetime_with_timezone :updated_at, null: false

      t.text :api_url
      t.text :ca_cert

      t.string :namespace

      t.string :username
      t.text :encrypted_password
      t.string :encrypted_password_iv

      t.text :encrypted_token
      t.string :encrypted_token_iv
    end

    create_table :cluster_providers_gcp do |t|
      t.references :cluster, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade }

      t.integer :status
      t.integer :num_nodes, null: false

      t.datetime_with_timezone :created_at, null: false
      t.datetime_with_timezone :updated_at, null: false

      t.text :status_reason

      t.string :gcp_project_id, null: false
      t.string :zone, null: false
      t.string :machine_type
      t.string :operation_id

      t.string :endpoint

      t.text :encrypted_access_token
      t.string :encrypted_access_token_iv
    end
  end
end