mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-19 13:54:25 +01:00
Compatible database with Fab-manager v1, to allow upgrades
This commit is contained in:
parent
de9c224a92
commit
f2a76732e5
@ -3,6 +3,7 @@
|
||||
- Improved version check
|
||||
- Improved setup script for installations without nginx
|
||||
- Changed some default values for new installations
|
||||
- Compatible database with Fab-manager v1, to allow upgrades
|
||||
- Updated documentation
|
||||
- Fix a bug: installation without nginx does not remove the service from the docker-compose file
|
||||
- Fix a bug: default twitter feed is invalid
|
||||
|
@ -3,8 +3,8 @@
|
||||
class CreateProjectsComponents < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
create_table :projects_components do |t|
|
||||
t.belongs_to :project, index: true
|
||||
t.belongs_to :component, index: true
|
||||
t.belongs_to :project, index: true
|
||||
t.belongs_to :component, index: true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -3,8 +3,8 @@
|
||||
class CreateProjectsThemes < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
create_table :projects_themes do |t|
|
||||
t.belongs_to :project, index: true
|
||||
t.belongs_to :theme, index: true
|
||||
t.belongs_to :project, index: true
|
||||
t.belongs_to :theme, index: true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -3,7 +3,7 @@
|
||||
class RenameCoursesWorkshopsToEvents < ActiveRecord::Migration[4.2]
|
||||
def up
|
||||
execute "UPDATE statistic_indices
|
||||
SET label='Évènements'
|
||||
SET label='Événements'
|
||||
WHERE es_type_key='event';"
|
||||
end
|
||||
|
||||
|
57
db/migrate/20200408101654_match_v1_models.rb
Normal file
57
db/migrate/20200408101654_match_v1_models.rb
Normal file
@ -0,0 +1,57 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# From this migration the data model will be retro-compatible with FabManager v1.x
|
||||
# This will allow easier upgrades
|
||||
class MatchV1Models < ActiveRecord::Migration[5.2]
|
||||
def up
|
||||
# migrate data from columns of type "varchar" to type "inet"
|
||||
add_column :users, :current_sign_in_ip_tmp, :inet
|
||||
add_column :users, :last_sign_in_ip_tmp, :inet
|
||||
User.reset_column_information
|
||||
User.all.each do |user|
|
||||
user.current_sign_in_ip_tmp = user.current_sign_in_ip
|
||||
user.last_sign_in_ip_tmp = user.last_sign_in_ip
|
||||
user.save
|
||||
end
|
||||
remove_column :users, :current_sign_in_ip, :string
|
||||
remove_column :users, :last_sign_in_ip, :string
|
||||
rename_column :users, :current_sign_in_ip_tmp, :current_sign_in_ip
|
||||
rename_column :users, :last_sign_in_ip_tmp, :last_sign_in_ip
|
||||
# add various foreign keys
|
||||
add_foreign_key :projects_machines, :projects
|
||||
add_foreign_key :projects_machines, :machines
|
||||
add_foreign_key :project_users, :projects
|
||||
add_foreign_key :project_users, :users
|
||||
add_foreign_key :project_steps, :projects
|
||||
add_foreign_key :projects_components, :projects
|
||||
add_foreign_key :projects_components, :components
|
||||
add_foreign_key :projects_themes, :projects
|
||||
add_foreign_key :projects_themes, :themes
|
||||
end
|
||||
|
||||
def down
|
||||
# migrate data from columns of type "inet" to type "varchar"
|
||||
add_column :users, :current_sign_in_ip_tmp, :string
|
||||
add_column :users, :last_sign_in_ip_tmp, :string
|
||||
User.reset_column_information
|
||||
User.all.each do |user|
|
||||
user.current_sign_in_ip_tmp = user.current_sign_in_ip
|
||||
user.last_sign_in_ip_tmp = user.last_sign_in_ip
|
||||
user.save
|
||||
end
|
||||
remove_column :users, :current_sign_in_ip, :inet
|
||||
remove_column :users, :last_sign_in_ip, :inet
|
||||
rename_column :users, :current_sign_in_ip_tmp, :current_sign_in_ip
|
||||
rename_column :users, :last_sign_in_ip_tmp, :last_sign_in_ip
|
||||
# remove the foreign keys
|
||||
remove_foreign_key :projects_machines, :projects
|
||||
remove_foreign_key :projects_machines, :machines
|
||||
remove_foreign_key :project_users, :projects
|
||||
remove_foreign_key :project_users, :users
|
||||
remove_foreign_key :project_steps, :projects
|
||||
remove_foreign_key :projects_components, :projects
|
||||
remove_foreign_key :projects_components, :components
|
||||
remove_foreign_key :projects_themes, :projects
|
||||
remove_foreign_key :projects_themes, :themes
|
||||
end
|
||||
end
|
39
db/schema.rb
39
db/schema.rb
@ -10,16 +10,16 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20200218092221) do
|
||||
ActiveRecord::Schema.define(version: 2020_04_08_101654) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pg_trgm"
|
||||
enable_extension "plpgsql"
|
||||
enable_extension "unaccent"
|
||||
enable_extension "pg_trgm"
|
||||
|
||||
create_table "abuses", id: :serial, force: :cascade do |t|
|
||||
t.string "signaled_type"
|
||||
t.integer "signaled_id"
|
||||
t.string "signaled_type"
|
||||
t.string "first_name"
|
||||
t.string "last_name"
|
||||
t.string "email"
|
||||
@ -48,8 +48,8 @@ ActiveRecord::Schema.define(version: 20200218092221) do
|
||||
t.string "locality"
|
||||
t.string "country"
|
||||
t.string "postal_code"
|
||||
t.string "placeable_type"
|
||||
t.integer "placeable_id"
|
||||
t.string "placeable_type"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
@ -63,8 +63,8 @@ ActiveRecord::Schema.define(version: 20200218092221) do
|
||||
end
|
||||
|
||||
create_table "assets", id: :serial, force: :cascade do |t|
|
||||
t.string "viewable_type"
|
||||
t.integer "viewable_id"
|
||||
t.string "viewable_type"
|
||||
t.string "attachment"
|
||||
t.string "type"
|
||||
t.datetime "created_at"
|
||||
@ -131,8 +131,8 @@ ActiveRecord::Schema.define(version: 20200218092221) do
|
||||
end
|
||||
|
||||
create_table "credits", id: :serial, force: :cascade do |t|
|
||||
t.string "creditable_type"
|
||||
t.integer "creditable_id"
|
||||
t.string "creditable_type"
|
||||
t.integer "plan_id"
|
||||
t.integer "hours"
|
||||
t.datetime "created_at"
|
||||
@ -284,8 +284,8 @@ ActiveRecord::Schema.define(version: 20200218092221) do
|
||||
end
|
||||
|
||||
create_table "invoices", id: :serial, force: :cascade do |t|
|
||||
t.string "invoiced_type"
|
||||
t.integer "invoiced_id"
|
||||
t.string "invoiced_type"
|
||||
t.string "stp_invoice_id"
|
||||
t.integer "total"
|
||||
t.datetime "created_at"
|
||||
@ -348,15 +348,15 @@ ActiveRecord::Schema.define(version: 20200218092221) do
|
||||
|
||||
create_table "notifications", id: :serial, force: :cascade do |t|
|
||||
t.integer "receiver_id"
|
||||
t.string "attached_object_type"
|
||||
t.integer "attached_object_id"
|
||||
t.string "attached_object_type"
|
||||
t.integer "notification_type_id"
|
||||
t.boolean "is_read", default: false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "receiver_type"
|
||||
t.boolean "is_send", default: false
|
||||
t.jsonb "meta_data", default: "{}"
|
||||
t.jsonb "meta_data", default: {}
|
||||
t.index ["notification_type_id"], name: "index_notifications_on_notification_type_id"
|
||||
t.index ["receiver_id"], name: "index_notifications_on_receiver_id"
|
||||
end
|
||||
@ -456,8 +456,8 @@ ActiveRecord::Schema.define(version: 20200218092221) do
|
||||
create_table "prices", id: :serial, force: :cascade do |t|
|
||||
t.integer "group_id"
|
||||
t.integer "plan_id"
|
||||
t.string "priceable_type"
|
||||
t.integer "priceable_id"
|
||||
t.string "priceable_type"
|
||||
t.integer "amount"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
@ -564,8 +564,8 @@ ActiveRecord::Schema.define(version: 20200218092221) do
|
||||
t.text "message"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "reservable_type"
|
||||
t.integer "reservable_id"
|
||||
t.string "reservable_type"
|
||||
t.integer "nb_reserve_places"
|
||||
t.integer "statistic_profile_id"
|
||||
t.index ["reservable_type", "reservable_id"], name: "index_reservations_on_reservable_type_and_reservable_id"
|
||||
@ -574,8 +574,8 @@ ActiveRecord::Schema.define(version: 20200218092221) do
|
||||
|
||||
create_table "roles", id: :serial, force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.string "resource_type"
|
||||
t.integer "resource_id"
|
||||
t.string "resource_type"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.index ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id"
|
||||
@ -814,8 +814,6 @@ ActiveRecord::Schema.define(version: 20200218092221) do
|
||||
t.integer "sign_in_count", default: 0, null: false
|
||||
t.datetime "current_sign_in_at"
|
||||
t.datetime "last_sign_in_at"
|
||||
t.string "current_sign_in_ip"
|
||||
t.string "last_sign_in_ip"
|
||||
t.string "confirmation_token"
|
||||
t.datetime "confirmed_at"
|
||||
t.datetime "confirmation_sent_at"
|
||||
@ -836,6 +834,8 @@ ActiveRecord::Schema.define(version: 20200218092221) do
|
||||
t.string "auth_token"
|
||||
t.datetime "merged_at"
|
||||
t.boolean "is_allow_newsletter"
|
||||
t.inet "current_sign_in_ip"
|
||||
t.inet "last_sign_in_ip"
|
||||
t.index ["auth_token"], name: "index_users_on_auth_token"
|
||||
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
|
||||
t.index ["email"], name: "index_users_on_email", unique: true
|
||||
@ -866,8 +866,8 @@ ActiveRecord::Schema.define(version: 20200218092221) do
|
||||
|
||||
create_table "wallet_transactions", id: :serial, force: :cascade do |t|
|
||||
t.integer "wallet_id"
|
||||
t.string "transactable_type"
|
||||
t.integer "transactable_id"
|
||||
t.string "transactable_type"
|
||||
t.string "transaction_type"
|
||||
t.integer "amount"
|
||||
t.datetime "created_at", null: false
|
||||
@ -909,9 +909,18 @@ ActiveRecord::Schema.define(version: 20200218092221) do
|
||||
add_foreign_key "organizations", "invoicing_profiles"
|
||||
add_foreign_key "prices", "groups"
|
||||
add_foreign_key "prices", "plans"
|
||||
add_foreign_key "project_steps", "projects"
|
||||
add_foreign_key "project_users", "projects"
|
||||
add_foreign_key "project_users", "users"
|
||||
add_foreign_key "projects", "statistic_profiles", column: "author_statistic_profile_id"
|
||||
add_foreign_key "projects_components", "components"
|
||||
add_foreign_key "projects_components", "projects"
|
||||
add_foreign_key "projects_machines", "machines"
|
||||
add_foreign_key "projects_machines", "projects"
|
||||
add_foreign_key "projects_spaces", "projects"
|
||||
add_foreign_key "projects_spaces", "spaces"
|
||||
add_foreign_key "projects_themes", "projects"
|
||||
add_foreign_key "projects_themes", "themes"
|
||||
add_foreign_key "reservations", "statistic_profiles"
|
||||
add_foreign_key "slots_reservations", "reservations"
|
||||
add_foreign_key "slots_reservations", "slots"
|
||||
|
Loading…
x
Reference in New Issue
Block a user