Created
March 2, 2016 07:01
-
-
Save AlexKalinin/9ff1aa22e801daf96f16 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class InitMigration < ActiveRecord::Migration | |
def change | |
create_table 'pictures', force: :cascade do |t| | |
t.string 'name', null: false | |
t.string 'guid', null: false | |
t.timestamps null: false | |
end | |
add_index :pictures, :guid, unique: true | |
create_table :collection_level_ones, force: :cascade do |t| | |
t.string :name, null: false | |
t.string :guid, null: false | |
t.belongs_to :picture, null: false, index: true | |
t.timestamps null: false | |
end | |
add_index :collection_level_ones, :guid, unique: true | |
add_foreign_key :collection_level_ones, :pictures, column: :picture_id, on_delete: :restrict | |
create_table 'nomenclatures', force: :cascade do |t| | |
t.string 'guid', null: false | |
t.string 'name', null: false | |
t.integer 'price', null: false | |
t.belongs_to :collection_level_one, null: false, index: true | |
t.text 'description', null: true | |
t.timestamps null: false | |
end | |
add_index :nomenclatures, :guid, unique: true | |
add_foreign_key :nomenclatures, :collection_level_ones, column: :collection_level_one_id, on_delete: :restrict | |
# -- | |
create_table 'nomenclatures_pictures', id: false, force: :cascade do |t| | |
t.belongs_to 'nomenclature', null: false, index: true | |
t.belongs_to 'picture', null: false, index: true | |
end | |
add_foreign_key :nomenclatures_pictures, :nomenclatures, column: :nomenclature_id, on_delete: :restrict | |
add_foreign_key :nomenclatures_pictures, :pictures, column: :picture_id, on_delete: :restrict | |
create_table 'orders', force: :cascade do |t| | |
t.text 'customer_name', null: false | |
t.text 'customer_phone', null: false | |
t.integer 'total_price', null: false | |
# 1 created, waiting the sinc with 1C | |
# 2 syncronized with 1C | |
t.integer 'state', null: false, default: 1 | |
t.timestamps null: false | |
end | |
create_table 'orders_nomenclatures', force: :cascade do |t| | |
t.belongs_to 'order', null: false, index: true | |
t.belongs_to 'nomenclature', null: false, index: true | |
t.string 'nomenclature_guid', null: false | |
t.text 'nomenclature_name', null: false | |
t.integer 'nomenclature_price', null: false | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment