diff --git a/README.md b/README.md index a45bb2c2c..fa529cc37 100644 --- a/README.md +++ b/README.md @@ -122,9 +122,12 @@ In you only intend to run fab-manager on your local machine for testing purposes ``` 8. Build the database. You may have to follow the steps described in [the PostgreSQL configuration chapter](#setup-fabmanager-in-postgresql) before, if you don't already had done it. + **Warning**: **NO NOT** run `rake db:setup` instead of these commands, as this will not run some required raw SQL instructions. ```bash - rake db:setup + rake db:create + rake db:migrate + rake db:seed ``` 9. Create the pids folder used by Sidekiq. If you want to use a different location, you can configure it in `config/sidekiq.yml` @@ -331,7 +334,7 @@ Otherwise, please follow the official instructions on the project's website. ### Setup the FabManager database in PostgreSQL -Before running `rake db:setup`, you have to make sure that the user configured in [config/database.yml](config/database.yml.default) for the `development` environment exists. +Before running `rake db:create`, you have to make sure that the user configured in [config/database.yml](config/database.yml.default) for the `development` environment exists. To create it, please follow these instructions: 1. Run the PostgreSQL administration command line interface, logged as the postgres user @@ -361,19 +364,13 @@ To create it, please follow these instructions: ALTER ROLE sleede WITH CREATEDB; ``` -4. Then, create the fabmanager_development and fabmanager_test databases - - ```sql - CREATE DATABASE fabmanager_development OWNER sleede; - CREATE DATABASE fabmanager_test OWNER sleede; - ``` - -5. To finish, attribute a password to this user +4. Then, attribute a password to this user ```sql ALTER USER sleede WITH ENCRYPTED PASSWORD 'sleede'; ``` -6. Finally, have a look at the [PostgreSQL Limitations](#postgresql-limitations) section or some errors will occurs preventing you from finishing the installation procedure. + +5. Finally, have a look at the [PostgreSQL Limitations](#postgresql-limitations) section or some errors will occurs preventing you from finishing the installation procedure. ### PostgreSQL Limitations diff --git a/db/migrate/20160830154719_migrate_event_reduced_amount_to_price_category.rb b/db/migrate/20160830154719_migrate_event_reduced_amount_to_price_category.rb index dccf986c5..c323b3037 100644 --- a/db/migrate/20160830154719_migrate_event_reduced_amount_to_price_category.rb +++ b/db/migrate/20160830154719_migrate_event_reduced_amount_to_price_category.rb @@ -29,21 +29,23 @@ class MigrateEventReducedAmountToPriceCategory < ActiveRecord::Migration def down pc = PriceCategory.find_by(name: I18n.t('price_category.reduced_fare')) - EventPriceCategory.where(price_category_id: pc.id).each do |epc| - epc.event.update_column(:reduced_amount, epc.amount) + unless pc.nil? + EventPriceCategory.where(price_category_id: pc.id).each do |epc| + epc.event.update_column(:reduced_amount, epc.amount) - Reservation.where(reservable_type: 'Event', reservable_id: epc.event.id).each do |r| - r.tickets.each do |t| - if t.event_price_category_id == epc.id - r.update_column(:nb_reserve_reduced_places, t.booked) - t.destroy! - break + Reservation.where(reservable_type: 'Event', reservable_id: epc.event.id).each do |r| + r.tickets.each do |t| + if t.event_price_category_id == epc.id + r.update_column(:nb_reserve_reduced_places, t.booked) + t.destroy! + break + end end end + epc.destroy! end - epc.destroy! - end - pc.destroy! + pc.destroy! + end end end diff --git a/db/schema.rb b/db/schema.rb index 6c97b8a68..5ce29dae2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -32,14 +32,14 @@ ActiveRecord::Schema.define(version: 20170213142543) do add_index "abuses", ["signaled_type", "signaled_id"], name: "index_abuses_on_signaled_type_and_signaled_id", using: :btree create_table "addresses", force: :cascade do |t| - t.string "address", limit: 255 - t.string "street_number", limit: 255 - t.string "route", limit: 255 - t.string "locality", limit: 255 - t.string "country", limit: 255 - t.string "postal_code", limit: 255 + t.string "address" + t.string "street_number" + t.string "route" + t.string "locality" + t.string "country" + t.string "postal_code" t.integer "placeable_id" - t.string "placeable_type", limit: 255 + t.string "placeable_type" t.datetime "created_at" t.datetime "updated_at" end @@ -55,9 +55,9 @@ ActiveRecord::Schema.define(version: 20170213142543) do create_table "assets", force: :cascade do |t| t.integer "viewable_id" - t.string "viewable_type", limit: 255 - t.string "attachment", limit: 255 - t.string "type", limit: 255 + t.string "viewable_type" + t.string "attachment" + t.string "type" t.datetime "created_at" t.datetime "updated_at" end @@ -74,11 +74,11 @@ ActiveRecord::Schema.define(version: 20170213142543) do create_table "availabilities", force: :cascade do |t| t.datetime "start_at" t.datetime "end_at" - t.string "available_type", limit: 255 + t.string "available_type" t.datetime "created_at" t.datetime "updated_at" t.integer "nb_total_places" - t.boolean "destroying", default: false + t.boolean "destroying", default: false end create_table "availability_tags", force: :cascade do |t| @@ -92,7 +92,7 @@ ActiveRecord::Schema.define(version: 20170213142543) do add_index "availability_tags", ["tag_id"], name: "index_availability_tags_on_tag_id", using: :btree create_table "categories", force: :cascade do |t| - t.string "name", limit: 255 + t.string "name" t.datetime "created_at" t.datetime "updated_at" t.string "slug" @@ -101,7 +101,7 @@ ActiveRecord::Schema.define(version: 20170213142543) do add_index "categories", ["slug"], name: "index_categories_on_slug", unique: true, using: :btree create_table "components", force: :cascade do |t| - t.string "name", limit: 255, null: false + t.string "name", null: false end create_table "coupons", force: :cascade do |t| @@ -119,7 +119,7 @@ ActiveRecord::Schema.define(version: 20170213142543) do create_table "credits", force: :cascade do |t| t.integer "creditable_id" - t.string "creditable_type", limit: 255 + t.string "creditable_type" t.integer "plan_id" t.integer "hours" t.datetime "created_at" @@ -160,7 +160,7 @@ ActiveRecord::Schema.define(version: 20170213142543) do add_index "event_themes", ["slug"], name: "index_event_themes_on_slug", unique: true, using: :btree create_table "events", force: :cascade do |t| - t.string "title", limit: 255 + t.string "title" t.text "description" t.datetime "created_at" t.datetime "updated_at" @@ -198,10 +198,10 @@ ActiveRecord::Schema.define(version: 20170213142543) do add_index "exports", ["user_id"], name: "index_exports_on_user_id", using: :btree create_table "friendly_id_slugs", force: :cascade do |t| - t.string "slug", limit: 255, null: false - t.integer "sluggable_id", null: false + t.string "slug", null: false + t.integer "sluggable_id", null: false t.string "sluggable_type", limit: 50 - t.string "scope", limit: 255 + t.string "scope" t.datetime "created_at" end @@ -211,17 +211,17 @@ ActiveRecord::Schema.define(version: 20170213142543) do add_index "friendly_id_slugs", ["sluggable_type"], name: "index_friendly_id_slugs_on_sluggable_type", using: :btree create_table "groups", force: :cascade do |t| - t.string "name", limit: 255 + t.string "name" t.datetime "created_at" t.datetime "updated_at" - t.string "slug", limit: 255 + t.string "slug" end add_index "groups", ["slug"], name: "index_groups_on_slug", unique: true, using: :btree create_table "invoice_items", force: :cascade do |t| t.integer "invoice_id" - t.string "stp_invoice_item_id", limit: 255 + t.string "stp_invoice_item_id" t.integer "amount" t.datetime "created_at" t.datetime "updated_at" @@ -234,17 +234,17 @@ ActiveRecord::Schema.define(version: 20170213142543) do create_table "invoices", force: :cascade do |t| t.integer "invoiced_id" - t.string "invoiced_type", limit: 255 - t.string "stp_invoice_id", limit: 255 + t.string "invoiced_type" + t.string "stp_invoice_id" t.integer "total" t.datetime "created_at" t.datetime "updated_at" t.integer "user_id" - t.string "reference", limit: 255 - t.string "avoir_mode", limit: 255 + t.string "reference" + t.string "avoir_mode" t.datetime "avoir_date" t.integer "invoice_id" - t.string "type", limit: 255 + t.string "type" t.boolean "subscription_to_expire" t.text "description" t.integer "wallet_amount" @@ -258,17 +258,17 @@ ActiveRecord::Schema.define(version: 20170213142543) do add_index "invoices", ["wallet_transaction_id"], name: "index_invoices_on_wallet_transaction_id", using: :btree create_table "licences", force: :cascade do |t| - t.string "name", limit: 255, null: false + t.string "name", null: false t.text "description" end create_table "machines", force: :cascade do |t| - t.string "name", limit: 255, null: false + t.string "name", null: false t.text "description" t.text "spec" t.datetime "created_at" t.datetime "updated_at" - t.string "slug", limit: 255 + t.string "slug" end add_index "machines", ["slug"], name: "index_machines_on_slug", unique: true, using: :btree @@ -284,14 +284,14 @@ ActiveRecord::Schema.define(version: 20170213142543) do create_table "notifications", force: :cascade do |t| t.integer "receiver_id" t.integer "attached_object_id" - t.string "attached_object_type", limit: 255 + t.string "attached_object_type" t.integer "notification_type_id" - t.boolean "is_read", default: false + t.boolean "is_read", default: false t.datetime "created_at" t.datetime "updated_at" - t.string "receiver_type", limit: 255 - t.boolean "is_send", default: false - t.jsonb "meta_data", default: {} + t.string "receiver_type" + t.boolean "is_send", default: false + t.jsonb "meta_data", default: {} end add_index "notifications", ["notification_type_id"], name: "index_notifications_on_notification_type_id", using: :btree @@ -360,20 +360,20 @@ ActiveRecord::Schema.define(version: 20170213142543) do add_index "organizations", ["profile_id"], name: "index_organizations_on_profile_id", using: :btree create_table "plans", force: :cascade do |t| - t.string "name", limit: 255 + t.string "name" t.integer "amount" - t.string "interval", limit: 255 + t.string "interval" t.integer "group_id" - t.string "stp_plan_id", limit: 255 + t.string "stp_plan_id" t.datetime "created_at" t.datetime "updated_at" - t.integer "training_credit_nb", default: 0 - t.boolean "is_rolling", default: true + t.integer "training_credit_nb", default: 0 + t.boolean "is_rolling", default: true t.text "description" t.string "type" t.string "base_name" - t.integer "ui_weight", default: 0 - t.integer "interval_count", default: 1 + t.integer "ui_weight", default: 0 + t.integer "interval_count", default: 1 t.string "slug" end @@ -402,11 +402,11 @@ ActiveRecord::Schema.define(version: 20170213142543) do create_table "profiles", force: :cascade do |t| t.integer "user_id" - t.string "first_name", limit: 255 - t.string "last_name", limit: 255 + t.string "first_name" + t.string "last_name" t.boolean "gender" t.date "birthday" - t.string "phone", limit: 255 + t.string "phone" t.text "interest" t.text "software_mastered" t.datetime "created_at" @@ -436,7 +436,7 @@ ActiveRecord::Schema.define(version: 20170213142543) do t.integer "project_id" t.datetime "created_at" t.datetime "updated_at" - t.string "title", limit: 255 + t.string "title" t.integer "step_nb" end @@ -447,23 +447,23 @@ ActiveRecord::Schema.define(version: 20170213142543) do t.integer "user_id" t.datetime "created_at" t.datetime "updated_at" - t.boolean "is_valid", default: false - t.string "valid_token", limit: 255 + t.boolean "is_valid", default: false + t.string "valid_token" end add_index "project_users", ["project_id"], name: "index_project_users_on_project_id", using: :btree add_index "project_users", ["user_id"], name: "index_project_users_on_user_id", using: :btree create_table "projects", force: :cascade do |t| - t.string "name", limit: 255 + t.string "name" t.text "description" t.datetime "created_at" t.datetime "updated_at" t.integer "author_id" t.text "tags" t.integer "licence_id" - t.string "state", limit: 255 - t.string "slug", limit: 255 + t.string "state" + t.string "slug" t.datetime "published_at" end @@ -507,19 +507,19 @@ ActiveRecord::Schema.define(version: 20170213142543) do t.datetime "created_at" t.datetime "updated_at" t.integer "reservable_id" - t.string "reservable_type", limit: 255 - t.string "stp_invoice_id", limit: 255 + t.string "reservable_type" + t.string "stp_invoice_id" t.integer "nb_reserve_places" end - add_index "reservations", ["reservable_id", "reservable_type"], name: "index_reservations_on_reservable_id_and_reservable_type", using: :btree + add_index "reservations", ["reservable_type", "reservable_id"], name: "index_reservations_on_reservable_type_and_reservable_id", using: :btree add_index "reservations", ["stp_invoice_id"], name: "index_reservations_on_stp_invoice_id", using: :btree add_index "reservations", ["user_id"], name: "index_reservations_on_user_id", using: :btree create_table "roles", force: :cascade do |t| - t.string "name", limit: 255 + t.string "name" t.integer "resource_id" - t.string "resource_type", limit: 255 + t.string "resource_type" t.datetime "created_at" t.datetime "updated_at" end @@ -544,8 +544,8 @@ ActiveRecord::Schema.define(version: 20170213142543) do t.datetime "updated_at" t.integer "availability_id" t.datetime "ex_start_at" - t.datetime "canceled_at" t.datetime "ex_end_at" + t.datetime "canceled_at" t.boolean "offered", default: false end @@ -586,18 +586,18 @@ ActiveRecord::Schema.define(version: 20170213142543) do create_table "statistic_fields", force: :cascade do |t| t.integer "statistic_index_id" - t.string "key", limit: 255 - t.string "label", limit: 255 + t.string "key" + t.string "label" t.datetime "created_at" t.datetime "updated_at" - t.string "data_type", limit: 255 + t.string "data_type" end add_index "statistic_fields", ["statistic_index_id"], name: "index_statistic_fields_on_statistic_index_id", using: :btree create_table "statistic_graphs", force: :cascade do |t| t.integer "statistic_index_id" - t.string "chart_type", limit: 255 + t.string "chart_type" t.integer "limit" t.datetime "created_at" t.datetime "updated_at" @@ -606,17 +606,17 @@ ActiveRecord::Schema.define(version: 20170213142543) do add_index "statistic_graphs", ["statistic_index_id"], name: "index_statistic_graphs_on_statistic_index_id", using: :btree create_table "statistic_indices", force: :cascade do |t| - t.string "es_type_key", limit: 255 - t.string "label", limit: 255 + t.string "es_type_key" + t.string "label" t.datetime "created_at" t.datetime "updated_at" - t.boolean "table", default: true - t.boolean "ca", default: true + t.boolean "table", default: true + t.boolean "ca", default: true end create_table "statistic_sub_types", force: :cascade do |t| - t.string "key", limit: 255 - t.string "label", limit: 255 + t.string "key" + t.string "label" t.datetime "created_at" t.datetime "updated_at" end @@ -633,8 +633,8 @@ ActiveRecord::Schema.define(version: 20170213142543) do create_table "statistic_types", force: :cascade do |t| t.integer "statistic_index_id" - t.string "key", limit: 255 - t.string "label", limit: 255 + t.string "key" + t.string "label" t.boolean "graph" t.datetime "created_at" t.datetime "updated_at" @@ -652,7 +652,7 @@ ActiveRecord::Schema.define(version: 20170213142543) do create_table "subscriptions", force: :cascade do |t| t.integer "plan_id" t.integer "user_id" - t.string "stp_subscription_id", limit: 255 + t.string "stp_subscription_id" t.datetime "created_at" t.datetime "updated_at" t.datetime "expired_at" @@ -671,7 +671,7 @@ ActiveRecord::Schema.define(version: 20170213142543) do add_index "tags", ["name"], name: "index_tags_on_name", unique: true, using: :btree create_table "themes", force: :cascade do |t| - t.string "name", limit: 255, null: false + t.string "name", null: false end create_table "tickets", force: :cascade do |t| @@ -686,13 +686,13 @@ ActiveRecord::Schema.define(version: 20170213142543) do add_index "tickets", ["reservation_id"], name: "index_tickets_on_reservation_id", using: :btree create_table "trainings", force: :cascade do |t| - t.string "name", limit: 255 + t.string "name" t.datetime "created_at" t.datetime "updated_at" t.integer "nb_total_places" - t.string "slug", limit: 255 + t.string "slug" t.text "description" - t.boolean "public_page", default: true + t.boolean "public_page", default: true end add_index "trainings", ["slug"], name: "index_trainings_on_slug", unique: true, using: :btree @@ -747,32 +747,32 @@ ActiveRecord::Schema.define(version: 20170213142543) do add_index "user_trainings", ["user_id"], name: "index_user_trainings_on_user_id", using: :btree create_table "users", force: :cascade do |t| - t.string "username", limit: 255 - t.string "email", limit: 255, default: "", null: false - t.string "encrypted_password", limit: 255, default: "", null: false - t.string "reset_password_token", limit: 255 + t.string "email", default: "", null: false + t.string "encrypted_password", default: "", null: false + t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0, null: false + 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", limit: 255 - t.string "last_sign_in_ip", limit: 255 - t.string "confirmation_token", limit: 255 + 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" - t.string "unconfirmed_email", limit: 255 - t.integer "failed_attempts", default: 0, null: false - t.string "unlock_token", limit: 255 + t.string "unconfirmed_email" + t.integer "failed_attempts", default: 0, null: false + t.string "unlock_token" t.datetime "locked_at" t.datetime "created_at" t.datetime "updated_at" - t.boolean "is_allow_contact", default: true + t.boolean "is_allow_contact", default: true t.integer "group_id" - t.string "stp_customer_id", limit: 255 - t.string "slug", limit: 255 - t.boolean "is_active", default: true - t.boolean "invoicing_disabled", default: false + t.string "stp_customer_id" + t.string "username" + t.string "slug" + t.boolean "is_active", default: true + t.boolean "invoicing_disabled", default: false t.string "provider" t.string "uid" t.string "auth_token" diff --git a/docker/README.md b/docker/README.md index 1d1855bd3..d4f8ec1d4 100644 --- a/docker/README.md +++ b/docker/README.md @@ -340,7 +340,9 @@ Copy the previously customized `nginx.conf.example` as `/home/core/fabmanager/co #### create/migrate/seed db -`docker-compose run --rm fabmanager bundle exec rake db:setup` +`docker-compose run --rm fabmanager bundle exec rake db:create` +`docker-compose run --rm fabmanager bundle exec rake db:migrate` +`docker-compose run --rm fabmanager bundle exec rake db:seed` #### build assets