replace db by previous version

new_user
JuliusR 8 months ago
parent a30090ff86
commit 4d553d793b
  1. 31
      db/migrate/001_create_suppliers.rb
  2. 33
      db/migrate/002_create_articles.rb
  3. 11
      db/migrate/003_add_list_to_article.rb
  4. 10
      db/migrate/004_new_wording.rb
  5. 15
      db/migrate/20110306172553_add_bnn_sync_to_suppliers.rb
  6. 15
      db/migrate/20120312184452_create_users.rb
  7. 18
      db/migrate/20120312190323_create_user_accesses.rb
  8. 11
      db/migrate/20121013164501_remove_article_lists_from_suppliers.rb
  9. 9
      db/migrate/20121017084147_add_admin_flag_to_users.rb
  10. 9
      db/migrate/20130627093146_add_category_to_article.rb
  11. 8
      db/migrate/20170901183454_add_mail_sync_to_supplier.rb
  12. 19
      db/migrate/20170901200146_add_salt_to_suppliers.rb
  13. 11
      db/migrate/20190811115732_generalize_ftp_sync_beyond_bnn.rb
  14. 85
      db/schema.rb
  15. 6
      db/seeds.rb

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

85
db/schema.rb generated

@ -0,0 +1,85 @@
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20190811115732) do
create_table "articles", :force => true do |t|
t.string "name", :null => false
t.integer "supplier_id", :null => false
t.string "number"
t.string "note"
t.string "manufacturer"
t.string "origin"
t.string "unit"
t.decimal "price", :precision => 8, :scale => 2, :default => 0.0, :null => false
t.decimal "tax", :precision => 3, :scale => 1, :default => 7.0, :null => false
t.decimal "deposit", :precision => 8, :scale => 2, :default => 0.0, :null => false
t.decimal "unit_quantity", :precision => 4, :scale => 1, :default => 1.0, :null => false
t.decimal "scale_quantity", :precision => 4, :scale => 2
t.decimal "scale_price", :precision => 8, :scale => 2
t.datetime "created_on"
t.datetime "updated_on"
t.string "category"
end
add_index "articles", ["name"], :name => "index_articles_on_name"
add_index "articles", ["number", "supplier_id"], :name => "index_articles_on_number_and_supplier_id", :unique => true
create_table "suppliers", :force => true do |t|
t.string "name", :null => false
t.string "address", :null => false
t.string "phone", :null => false
t.string "phone2"
t.string "fax"
t.string "email"
t.string "url"
t.string "delivery_days"
t.string "note"
t.datetime "created_on"
t.datetime "updated_on"
t.boolean "ftp_sync", :default => false
t.string "ftp_host"
t.string "ftp_user"
t.string "ftp_password"
t.string "ftp_type", :default => "bnn", :null => false
t.string "ftp_regexp", :default => "^([.]/)?PL"
t.boolean "mail_sync"
t.string "mail_from"
t.string "mail_subject"
t.string "mail_type"
t.string "salt", :null => false
end
add_index "suppliers", ["name"], :name => "index_suppliers_on_name", :unique => true
create_table "user_accesses", :force => true do |t|
t.integer "user_id"
t.integer "supplier_id"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "user_accesses", ["supplier_id"], :name => "index_user_accesses_on_supplier_id"
add_index "user_accesses", ["user_id", "supplier_id"], :name => "index_user_accesses_on_user_id_and_supplier_id"
add_index "user_accesses", ["user_id"], :name => "index_user_accesses_on_user_id"
create_table "users", :force => true do |t|
t.string "email"
t.string "password_hash"
t.string "password_salt"
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "admin", :default => false
end
end

@ -1,7 +1,7 @@
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Character.create(name: 'Luke', movie: movies.first)
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Mayor.create(:name => 'Daley', :city => cities.first)

Loading…
Cancel
Save