diff --git a/app/models/organization.rb b/app/models/organization.rb new file mode 100644 index 000000000..1b556b972 --- /dev/null +++ b/app/models/organization.rb @@ -0,0 +1,4 @@ +class Organization < ActiveRecord::Base + has_one :address, as: :placeable, dependent: :destroy + accepts_nested_attributes_for :address, allow_destroy: true +end diff --git a/db/migrate/20160801145502_create_organizations.rb b/db/migrate/20160801145502_create_organizations.rb new file mode 100644 index 000000000..e7fe75b6c --- /dev/null +++ b/db/migrate/20160801145502_create_organizations.rb @@ -0,0 +1,9 @@ +class CreateOrganizations < ActiveRecord::Migration + def change + create_table :organizations do |t| + t.string :name + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20160801153454_add_organization_to_profile.rb b/db/migrate/20160801153454_add_organization_to_profile.rb new file mode 100644 index 000000000..9eadaccaf --- /dev/null +++ b/db/migrate/20160801153454_add_organization_to_profile.rb @@ -0,0 +1,5 @@ +class AddOrganizationToProfile < ActiveRecord::Migration + def change + add_reference :profiles, :organization, index: true, foreign_key: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 357678e37..1fbf226e9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160728095026) do +ActiveRecord::Schema.define(version: 20160801153454) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -324,6 +324,12 @@ ActiveRecord::Schema.define(version: 20160728095026) do t.datetime "updated_at", null: false end + create_table "organizations", force: :cascade do |t| + t.string "name" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "plans", force: :cascade do |t| t.string "name", limit: 255 t.integer "amount" @@ -384,8 +390,10 @@ ActiveRecord::Schema.define(version: 20160728095026) do t.string "lastfm" t.string "flickr" t.string "job" + t.integer "organization_id" end + add_index "profiles", ["organization_id"], name: "index_profiles_on_organization_id", using: :btree add_index "profiles", ["user_id"], name: "index_profiles_on_user_id", using: :btree create_table "project_steps", force: :cascade do |t| @@ -751,6 +759,7 @@ ActiveRecord::Schema.define(version: 20160728095026) do add_foreign_key "open_api_calls_count_tracings", "open_api_clients" add_foreign_key "prices", "groups" add_foreign_key "prices", "plans" + add_foreign_key "profiles", "organizations" add_foreign_key "user_tags", "tags" add_foreign_key "user_tags", "users" add_foreign_key "wallet_transactions", "users" diff --git a/test/fixtures/organizations.yml b/test/fixtures/organizations.yml new file mode 100644 index 000000000..56066c68a --- /dev/null +++ b/test/fixtures/organizations.yml @@ -0,0 +1,7 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + +two: + name: MyString diff --git a/test/models/organization_test.rb b/test/models/organization_test.rb new file mode 100644 index 000000000..d144816ef --- /dev/null +++ b/test/models/organization_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class OrganizationTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end