summaryrefslogtreecommitdiff
path: root/db/migrate/20170924094327_create_ci_clusters.rb
blob: 7a35fe35605684c535a61c240a5028a3b7b299e3 (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
class CreateCiClusters < ActiveRecord::Migration
  DOWNTIME = false

  def up
    create_table :ci_clusters do |t|
      t.integer :project_id
      t.integer :owner_id
      t.integer :service_id

      # General
      t.boolean :enabled, default: true
      t.integer :creation_type # manual or on_gke

      # k8s integration specific
      t.string :project_namespace

      # Cluster details
      t.string :end_point
      t.text :ca_cert
      t.string :token
      t.string :username
      t.string :password

      # GKE
      t.string :gcp_project_id
      t.string :cluster_zone
      t.string :cluster_name

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

    # create_table :ci_gke_clusters do |t|
    #   t.integer :ci_cluster_id
    #   t.string :gcp_project_id
    #   t.string :cluster_zone
    #   t.string :cluster_name
    # end
    # add_foreign_key :ci_gke_clusters, :ci_clusters

    # TODO: fk, index, encypt

    add_foreign_key :ci_clusters, :projects
    add_foreign_key :ci_clusters, :users, column: :owner_id
    add_foreign_key :ci_clusters, :services
  end

  def down
    drop_table :ci_clusters
  end
end