replace db by previous version
This commit is contained in:
parent
a30090ff86
commit
4d553d793b
15 changed files with 288 additions and 3 deletions
31
db/migrate/001_create_suppliers.rb
Normal file
31
db/migrate/001_create_suppliers.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
class CreateSuppliers < ActiveRecord::Migration
|
||||
SUPPLIER_SAMPLE = 'Sample Supplier'
|
||||
|
||||
def self.up
|
||||
create_table :suppliers do |t|
|
||||
t.column :name, :string, :null => false
|
||||
t.column :address, :string, :null => false
|
||||
t.column :phone, :string, :null => false
|
||||
t.column :phone2, :string
|
||||
t.column :fax, :string
|
||||
t.column :email, :string
|
||||
t.column :url, :string
|
||||
t.column :delivery_days, :string
|
||||
t.column :note, :string
|
||||
|
||||
t.column :created_on, :datetime
|
||||
t.column :updated_on, :datetime
|
||||
end
|
||||
add_index(:suppliers, :name, :unique => true)
|
||||
|
||||
# Create sample supplier...
|
||||
puts "Creating sample supplier '#{SUPPLIER_SAMPLE}'..."
|
||||
Supplier.create(:name => SUPPLIER_SAMPLE, :address => "Organic City", :phone => "0123-555555")
|
||||
raise "Failed!" unless supplier = Supplier.find_by_name(SUPPLIER_SAMPLE)
|
||||
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :suppliers
|
||||
end
|
||||
end
|
33
db/migrate/002_create_articles.rb
Normal file
33
db/migrate/002_create_articles.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
class CreateArticles < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :articles do |t|
|
||||
t.column :name, :string, :null => false
|
||||
t.column :supplier_id, :integer, :null => false
|
||||
t.column :number, :string
|
||||
t.column :note, :string
|
||||
t.column :manufacturer , :string
|
||||
t.column :origin, :string
|
||||
t.column :unit, :string
|
||||
|
||||
# now the price and order conditions
|
||||
t.column :price, :decimal, :precision => 8, :scale => 2, :null => false, :default => 0.00
|
||||
t.column :tax, :decimal, :precision => 3, :scale => 1,:null => false, :default => 7.0
|
||||
t.column :refund, :decimal, :precision => 8, :scale => 2, :null => false, :default => 0.00
|
||||
t.column :unit_quantity, :decimal, :precision => 4, :scale => 1,:null => false, :default => 1
|
||||
|
||||
# the price-quantity-scale
|
||||
t.column :scale_quantity, :decimal, :precision => 4, :scale => 2
|
||||
t.column :scale_price, :decimal, :precision => 8, :scale => 2
|
||||
|
||||
t.column :created_on, :datetime
|
||||
t.column :updated_on, :datetime
|
||||
|
||||
end
|
||||
add_index(:articles, :name)
|
||||
add_index(:articles, [:number, :supplier_id], :unique => true)
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :articles
|
||||
end
|
||||
end
|
11
db/migrate/003_add_list_to_article.rb
Normal file
11
db/migrate/003_add_list_to_article.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
class AddListToArticle < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_column :articles, :list, :string
|
||||
add_column :suppliers, :lists, :string
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column :articles, :list
|
||||
remove_column :suppliers, :lists
|
||||
end
|
||||
end
|
10
db/migrate/004_new_wording.rb
Normal file
10
db/migrate/004_new_wording.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
class NewWording < ActiveRecord::Migration
|
||||
def self.up
|
||||
rename_column :articles, :refund, :deposit
|
||||
# and make 0.0 deposit the default ...
|
||||
change_column :articles, :deposit, :decimal, :precision => 8, :scale => 2, :default => 0.0, :null => false
|
||||
end
|
||||
|
||||
def self.down
|
||||
end
|
||||
end
|
15
db/migrate/20110306172553_add_bnn_sync_to_suppliers.rb
Normal file
15
db/migrate/20110306172553_add_bnn_sync_to_suppliers.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
class AddBnnSyncToSuppliers < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_column :suppliers, :bnn_sync, :boolean, :default => false
|
||||
add_column :suppliers, :bnn_host, :string
|
||||
add_column :suppliers, :bnn_user, :string
|
||||
add_column :suppliers, :bnn_password, :string
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column :suppliers, :bnn_password
|
||||
remove_column :suppliers, :bnn_user
|
||||
remove_column :suppliers, :bnn_host
|
||||
remove_column :suppliers, :bnn_sync
|
||||
end
|
||||
end
|
15
db/migrate/20120312184452_create_users.rb
Normal file
15
db/migrate/20120312184452_create_users.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
class CreateUsers < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :users do |t|
|
||||
t.string :email
|
||||
t.string :password_hash
|
||||
t.string :password_salt
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :users
|
||||
end
|
||||
end
|
18
db/migrate/20120312190323_create_user_accesses.rb
Normal file
18
db/migrate/20120312190323_create_user_accesses.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
class CreateUserAccesses < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :user_accesses do |t|
|
||||
t.integer :user_id
|
||||
t.integer :supplier_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :user_accesses, :user_id
|
||||
add_index :user_accesses, :supplier_id
|
||||
add_index :user_accesses, [:user_id, :supplier_id]
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :user_accesses
|
||||
end
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
class RemoveArticleListsFromSuppliers < ActiveRecord::Migration
|
||||
def self.up
|
||||
remove_column :suppliers, :lists
|
||||
remove_column :articles, :list
|
||||
end
|
||||
|
||||
def self.down
|
||||
add_column :articles, :list, :string
|
||||
add_column :suppliers, :lists, :string
|
||||
end
|
||||
end
|
9
db/migrate/20121017084147_add_admin_flag_to_users.rb
Normal file
9
db/migrate/20121017084147_add_admin_flag_to_users.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
class AddAdminFlagToUsers < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_column :users, :admin, :boolean, :default => false
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column :users, :admin
|
||||
end
|
||||
end
|
9
db/migrate/20130627093146_add_category_to_article.rb
Normal file
9
db/migrate/20130627093146_add_category_to_article.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
class AddCategoryToArticle < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_column :articles, :category, :string
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column :articles, :category
|
||||
end
|
||||
end
|
8
db/migrate/20170901183454_add_mail_sync_to_supplier.rb
Normal file
8
db/migrate/20170901183454_add_mail_sync_to_supplier.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
class AddMailSyncToSupplier < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :suppliers, :mail_sync, :boolean
|
||||
add_column :suppliers, :mail_from, :string
|
||||
add_column :suppliers, :mail_subject, :string
|
||||
add_column :suppliers, :mail_type, :string
|
||||
end
|
||||
end
|
19
db/migrate/20170901200146_add_salt_to_suppliers.rb
Normal file
19
db/migrate/20170901200146_add_salt_to_suppliers.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
class AddSaltToSuppliers < ActiveRecord::Migration
|
||||
|
||||
class Supplier < ActiveRecord::Base; end
|
||||
|
||||
def up
|
||||
add_column :suppliers, :salt, :string
|
||||
|
||||
Supplier.find_each do |supplier|
|
||||
salt = [Array.new(6){rand(256).chr}.join].pack("m").chomp
|
||||
supplier.update_attributes! salt: salt
|
||||
end
|
||||
|
||||
change_column_null :suppliers, :salt, false
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :suppliers, :salt
|
||||
end
|
||||
end
|
11
db/migrate/20190811115732_generalize_ftp_sync_beyond_bnn.rb
Normal file
11
db/migrate/20190811115732_generalize_ftp_sync_beyond_bnn.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
class GeneralizeFtpSyncBeyondBnn < ActiveRecord::Migration
|
||||
def change
|
||||
rename_column :suppliers, :bnn_sync, :ftp_sync
|
||||
rename_column :suppliers, :bnn_host, :ftp_host
|
||||
rename_column :suppliers, :bnn_user, :ftp_user
|
||||
rename_column :suppliers, :bnn_password, :ftp_password
|
||||
|
||||
add_column :suppliers, :ftp_type, :string, default: 'bnn', null: false, after: :ftp_password
|
||||
add_column :suppliers, :ftp_regexp, :string, default: '^([.]/)?PL', after: :ftp_type
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue