1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00

put invoicing data into separate table

This commit is contained in:
Sylvain 2019-05-21 16:07:40 +02:00
parent b423d9fce7
commit 6cdce94912
6 changed files with 72 additions and 2 deletions

View File

@ -0,0 +1,5 @@
class InvoicingProfile < ActiveRecord::Base
belongs_to :user
belongs_to :address
belongs_to :organization
end

View File

@ -0,0 +1,13 @@
class CreateInvoicingProfiles < ActiveRecord::Migration
def change
create_table :invoicing_profiles do |t|
t.references :user, index: true, foreign_key: true
t.string :first_name
t.string :last_name
t.references :address, index: true, foreign_key: true
t.references :organization, index: true, foreign_key: true
t.timestamps null: false
end
end
end

View File

@ -0,0 +1,13 @@
class MigrateProfileToInvoicingProfile < ActiveRecord::Migration
def up
Profile.all.each do |p|
InvoicingProfile.create!(
user: p.user,
first_name: p.first_name,
last_name: p.last_name,
address: p.address,
organization: p.organization
)
end
end
end

View File

@ -11,12 +11,12 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20190320091148) do
ActiveRecord::Schema.define(version: 20190521124609) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
enable_extension "unaccent"
enable_extension "pg_trgm"
enable_extension "unaccent"
create_table "abuses", force: :cascade do |t|
t.integer "signaled_id"
@ -287,6 +287,20 @@ ActiveRecord::Schema.define(version: 20190320091148) do
add_index "invoices", ["user_id"], name: "index_invoices_on_user_id", using: :btree
add_index "invoices", ["wallet_transaction_id"], name: "index_invoices_on_wallet_transaction_id", using: :btree
create_table "invoicing_profiles", force: :cascade do |t|
t.integer "user_id"
t.string "first_name"
t.string "last_name"
t.integer "address_id"
t.integer "organization_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "invoicing_profiles", ["address_id"], name: "index_invoicing_profiles_on_address_id", using: :btree
add_index "invoicing_profiles", ["organization_id"], name: "index_invoicing_profiles_on_organization_id", using: :btree
add_index "invoicing_profiles", ["user_id"], name: "index_invoicing_profiles_on_user_id", using: :btree
create_table "licences", force: :cascade do |t|
t.string "name", null: false
t.text "description"
@ -886,6 +900,9 @@ ActiveRecord::Schema.define(version: 20190320091148) do
add_foreign_key "invoices", "coupons"
add_foreign_key "invoices", "users", column: "operator_id"
add_foreign_key "invoices", "wallet_transactions"
add_foreign_key "invoicing_profiles", "addresses"
add_foreign_key "invoicing_profiles", "organizations"
add_foreign_key "invoicing_profiles", "users"
add_foreign_key "o_auth2_mappings", "o_auth2_providers"
add_foreign_key "open_api_calls_count_tracings", "open_api_clients"
add_foreign_key "organizations", "profiles"

15
test/fixtures/invoicing_profiles.yml vendored Normal file
View File

@ -0,0 +1,15 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
user_id:
first_name: MyString
last_name: MyString
address_id:
organization_id:
two:
user_id:
first_name: MyString
last_name: MyString
address_id:
organization_id:

View File

@ -0,0 +1,7 @@
require 'test_helper'
class InvoicingProfileTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end