Skip to content

Commit

Permalink
revised migrations #21150
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Ammann committed Oct 31, 2016
1 parent 7d00486 commit 4a4b51c
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 146 deletions.
76 changes: 0 additions & 76 deletions db/migrate/20161003115930_legacy_schema.rb

This file was deleted.

63 changes: 0 additions & 63 deletions db/migrate/20161003130519_initial_db_setup.rb

This file was deleted.

79 changes: 79 additions & 0 deletions db/migrate/20161031081645_initial_schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
class InitialSchema < ActiveRecord::Migration[5.0]
def change
ActiveRecord::Base.connection.tables
unless ActiveRecord::Base.connection.table_exists? 'person'
create_table :statuses do |t|
t.string :status
end

create_table :people do |t|
t.timestamp :birthdate
t.column :profile_picture, 'bytea', null: false
t.string :language
t.string :location
t.string :martial_status
t.timestamp :updated_at
t.string :updated_by
t.datetime :created_at
t.string :name
t.string :origin
t.string :role
t.string :title
t.integer :status_id
t.integer :origin_person_id
t.string :variation_name
t.timestamp :variation_date
end

create_table :advanced_trainings do |t|
t.text :description
t.timestamp :updated_at
t.string :updated_by
t.datetime :created_at
t.integer :year_from
t.integer :year_to
t.integer :person_id
end

create_table :activities do |t|
t.text :description
t.timestamp :updated_at
t.string :updated_by
t.datetime :created_at
t.text :role
t.integer :year_from
t.integer :year_to
t.integer :person_id
end

create_table :projects do |t|
t.timestamp :updated_at
t.string :updated_by
t.datetime :created_at
t.text :description
t.text :title
t.text :role
t.text :technology
t.integer :year_to
t.integer :person_id
end

create_table :educations do |t|
t.text :location
t.text :type
t.timestamp :updated_at
t.string :updated_by
t.integer :year_from
t.integer :year_to
t.integer :person_id
end

create_table :competences do |t|
t.text :description
t.timestamp :updated_at
t.string :updated_by
t.integer :person_id
end
end
end
end
65 changes: 65 additions & 0 deletions db/migrate/20161031092413_update_legacy_schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
class UpdateLegacySchema < ActiveRecord::Migration[5.0]
def change
#Table statuses
ActiveRecord::Base.connection.tables
if ActiveRecord::Base.connection.table_exists? 'person'
rename_table :status, :statuses

#Table persons
rename_table :person, :people
rename_column :people, :image, :profile_picture
rename_column :people, :martialstatus, :martial_status
rename_column :people, :moddate, :updated_at
add_column :people, :created_at, :timestamp
rename_column :people, :moduser, :updated_by
rename_column :people, :fk_status, :status_id
rename_column :people, :rel_id, :variation_id

#Table advanced_trainings
rename_table :advancedtraining, :advanced_trainings
rename_column :advanced_trainings, :moddate, :updated_at
add_column :advanced_trainings, :created_at, :timestamp
rename_column :advanced_trainings, :moduser, :updated_by
rename_column :advanced_trainings, :yearfrom, :year_from
rename_column :advanced_trainings, :yearto, :year_to
rename_column :advanced_trainings, :fk_person, :person_id

#Table activities
rename_table :activity, :activities
rename_column :activities, :moddate, :updated_at
add_column :activities, :created_at, :timestamp
rename_column :activities, :moduser, :updated_by
rename_column :activities, :yearfrom, :year_from
rename_column :activities, :yearto, :year_to
rename_column :activities, :fk_person, :person_id

#Table projects
rename_table :project, :projects
rename_column :projects, :moddate, :updated_at
add_column :projects, :created_at, :timestamp
rename_column :projects, :moduser, :updated_by
rename_column :projects, :projectdescription, :description
rename_column :projects, :projecttitle, :title
rename_column :projects, :yearto, :year_to
rename_column :projects, :fk_person, :person_id

#Table educations
rename_table :education, :educations
rename_column :educations, :educationlocation, :location
rename_column :educations, :educationtype, :type
rename_column :educations, :moddate, :updated_at
add_column :educations, :created_at, :timestamp
rename_column :educations, :moduser, :updated_by
rename_column :educations, :yearfrom, :year_from
rename_column :educations, :yearto, :year_to
rename_column :educations, :fk_person, :person_id

#Table competences
rename_table :competence, :competences
rename_column :competences, :moddate, :updated_at
add_column :competences, :created_at, :timestamp
rename_column :competences, :moduser, :updated_by
rename_column :competences, :fk_person, :person_id
end
end
end
12 changes: 5 additions & 7 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20161021131003) do
ActiveRecord::Schema.define(version: 20161031092413) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand All @@ -19,29 +19,28 @@
t.text "description"
t.datetime "updated_at"
t.string "updated_by"
t.datetime "created_at"
t.text "role"
t.integer "year_from"
t.integer "year_to"
t.integer "person_id"
t.datetime "created_at"
end

create_table "advanced_trainings", force: :cascade do |t|
t.text "description"
t.datetime "updated_at"
t.string "updated_by"
t.datetime "created_at"
t.integer "year_from"
t.integer "year_to"
t.integer "person_id"
t.datetime "created_at"
end

create_table "competences", force: :cascade do |t|
t.text "description"
t.datetime "updated_at"
t.string "updated_by"
t.integer "person_id"
t.datetime "created_at"
end

create_table "educations", force: :cascade do |t|
Expand All @@ -52,7 +51,6 @@
t.integer "year_from"
t.integer "year_to"
t.integer "person_id"
t.datetime "created_at"
end

create_table "people", force: :cascade do |t|
Expand All @@ -63,6 +61,7 @@
t.string "martial_status"
t.datetime "updated_at"
t.string "updated_by"
t.datetime "created_at"
t.string "name"
t.string "origin"
t.string "role"
Expand All @@ -71,19 +70,18 @@
t.integer "origin_person_id"
t.string "variation_name"
t.datetime "variation_date"
t.datetime "created_at"
end

create_table "projects", force: :cascade do |t|
t.datetime "updated_at"
t.string "updated_by"
t.datetime "created_at"
t.text "description"
t.text "title"
t.text "role"
t.text "technology"
t.integer "year_to"
t.integer "person_id"
t.datetime "created_at"
end

create_table "statuses", force: :cascade do |t|
Expand Down
Binary file removed db/seeds/development/.statuses.rb.swp
Binary file not shown.
Binary file removed db/seeds/support/.person_seeder.rb.swo
Binary file not shown.
Empty file removed log/development.log
Empty file.

0 comments on commit 4a4b51c

Please sign in to comment.