repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/app/models/loans/form.rb | app/models/loans/form.rb | # encoding: utf-8
# author: Boris Barroso
# email: boriscyber@gmail.com
class Loans::Form < BaseForm
attribute :contact_id, Integer
attribute :account_to_id, Integer
attribute :date, Date
attribute :due_date, Date
attribute :total, Decimal, default: 0
attribute :reference, String
attribute :description, S... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/app/models/loans/give.rb | app/models/loans/give.rb | # encoding: utf-8
# author: Boris Barroso
# email: boriscyber@gmail.com
# Class for receiving loans
class Loans::Give < Loan
self.code_name = 'PG'
# Relationships
has_many :ledger_ins, -> { where(operation: 'lgcre') }, class_name: 'AccountLedger', foreign_key: :account_id
has_many :payments, -> { where(opera... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/app/models/loans/query.rb | app/models/loans/query.rb | class Loans::Query
def self.all_loans
Account.where(type: %w(Loans::Receive Loans::Give))
.includes(:contact, :creator, :updater)
end
def self.filter(args = {})
loans = loan_type(args)
loans = loans.joins(:contact).where("contacts.matchcode ILIKE ?", "%#{args[:search]}%") if args[:search].pres... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/app/models/loans/receive_payment_form.rb | app/models/loans/receive_payment_form.rb | # class for to make payments for Loans received the money goes out
# author: Boris Barroso
# email: boriscyber@gmail.com
class Loans::ReceivePaymentForm < Loans::PaymentForm
validate :valid_income_amount, if: :account_to_is_income?
def create_payment
return false unless valid?
res = true
commit_or_r... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/app/models/items/query.rb | app/models/items/query.rb | class Items::Query < SimpleDelegator
def initialize(rel = Item)
super(rel)
end
def search_items_with_stock(search, store_id)
items = active.search(search).limit(20)
items.map do |v|
ItemStock.new(v , stocks_hash(items.map(&:id), store_id))
end
end
end
| ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/app/models/movements/details.rb | app/models/movements/details.rb | # encoding: utf-8
# author: Boris Barroso
# email: boriscyber@gmail.com
class Movements::Details < Struct.new(:movement)
delegate :details, to: :movement
def set_details
details.each do |det|
det.price = det.price || 0
det.quantity = det.quantity || 0
det.original_price = item_... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/app/models/movements/export.rb | app/models/movements/export.rb | # encoding: utf-8
# author: Boris Barroso
# email: boriscyber@gmail.com
require 'csv'
class Movements::Export
attr_reader :col_sep, :rate, :date_range
def initialize(dr)
@date_range = dr
end
delegate :currency, to: OrganisationSession
def export(rel, col_sep = ",")
CSV.generate(col_sep: col_sep) d... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/app/models/movements/errors.rb | app/models/movements/errors.rb | class Movements::Errors < Struct.new(:movement)
attr_reader :errors
delegate :balance, :total, to: :movement
def set_errors
movement.has_error = false
@errors = {}
balance_errors
inventory_errors
set_error_messages
end
private
def balance_errors
greater_balance_than_total
... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/app/models/movements/form.rb | app/models/movements/form.rb | # encoding: utf-8
# author: Boris Barroso
# email: boriscyber@gmail.com
class Movements::Form < BaseForm
attribute :id, Integer
attribute :date, Date
attribute :due_date, Date
attribute :contact_id, Integer
attribute :currency, String
attribute :exchange_rate, Decimal, default: 1
attribute :project_id, In... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/app/models/movements/query.rb | app/models/movements/query.rb | # encoding: utf-8
# author: Boris Barroso
# email: boriscyber@gmail.com
class Movements::Query
attr_reader :rel
def initialize(relation)
@rel = relation
end
def index(params = {})
self.class.index_includes movement_set(params)
end
def search(s)
@rel.joins(:contact)
.where("accounts.name I... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/app/models/movements/search.rb | app/models/movements/search.rb | # class to help search
class Movements::Search
attr_reader :args, :model
def initialize(args = {}, model)
@args = args
@model = model
end
def search
s = model.includes(:contact, :tax, :updater, :creator, :approver, :nuller)
#.joins(:contact)
if args[:search].present?
s = s.where("ac... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/app/models/movements/details_calculations.rb | app/models/movements/details_calculations.rb | # encoding: utf-8
# author: Boris Barroso
# email: boriscyber@gmail.com
class Movements::DetailsCalculations < Struct.new(:movement)
delegate :details, to: :movement
def subtotal
details.inject(0) {|sum, det| sum += det.total }
end
def original_total
details.inject(0) {|sum, det| sum += det.quantity.t... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/app/models/movements/service.rb | app/models/movements/service.rb | # Related logic for income and expense
class Movements::Service < Struct.new(:movement)
attr_accessor :movement_history, :attributes_class
# Delegates
delegate :percentage, to: :tax, prefix: true
delegate :tax_id, :tax_in_out?, :details, to: :movement
delegate :set_details, to: :details_service
delegate :d... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/app/models/movements/history.rb | app/models/movements/history.rb | # Class to track history on movements
# test on spec/models/history_spec.rb
class Movements::History
attr_reader :details_col, :histo, :movement
delegate :state, :state_was, :state_changed?,
:date, :date_was, :date_chaged?, :to_s,
:due_date, :due_date_was, :due_date_changed?,
to: :... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/app/metal/base_app.rb | app/metal/base_app.rb | # encoding: utf-8
# author: Boris Barroso
# email: boriscyber@gmail.com
class BaseApp < ActionController::Metal
private
def set_search_path
PgTools.change_schema request.subdomain if request.subdomain.present?
end
end
| ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/app/metal/autocomplete_app.rb | app/metal/autocomplete_app.rb | # encoding: utf-8
# author: Boris Barroso
# email: boriscyber@gmail.com
class AutocompleteApp < BaseApp
include ActionController::Rendering
include ActionController::Renderers::All
def supplier
render :json => contact_autocomplete('Supplier', params)
end
def staff
render :json => contact_autocompl... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/app/inputs/select2_input.rb | app/inputs/select2_input.rb | class Select2Input < SimpleForm::Inputs::Base
include ActionView::Helpers::FormTagHelper
#enable :placeholder
# User the input_options[:value_field for the value of the relation Model
def input
if object.respond_to? :reflections
hid_name = object.reflections[attribute_name].foreign_key || :"#{attribu... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/app/inputs/datepicker_input.rb | app/inputs/datepicker_input.rb | class DatepickerInput < SimpleForm::Inputs::Base
include ActionView::Helpers::FormTagHelper
# User the input_options[:value_field for the value of the relation Model
def input
input_html_options[:size] ||= 10
out = @builder.hidden_field attribute_name, input_html_options
out << text_field_tag("#{att... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/app/inputs/autocomplete_input.rb | app/inputs/autocomplete_input.rb | class AutocompleteInput < SimpleForm::Inputs::Base
include ActionView::Helpers::FormTagHelper
# User the input_options[:value_field for the value of the relation Model
def input
value_field = input_options[:value_field] || :to_s
if object.respond_to? :reflections
hid_name = object.reflections[attr... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/app/inputs/contact_input.rb | app/inputs/contact_input.rb | # encoding: utf-8
# author: Boris Barroso
# email: boriscyber@gmail.com
class ContactInput < SimpleForm::Inputs::Base
def input
klass = @builder.object.send(:"#{ attribute_name.to_s.gsub(/_id$/, "") }")
if klass
klass = klass.accountable if klass.class.to_s == "Account"
input_html_options['data-t... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/app/mailers/reset_password_mailer.rb | app/mailers/reset_password_mailer.rb | # encoding: utf-8
class ResetPasswordMailer < ActionMailer::Base
default from: "#{APP_NAME} <noresponder@#{DOMAIN}>"
layout "email"
# Sends the registration email to the contact
def send_reset_password(user)
@user = user
@host = ActionMailer::Base.default_url_options[:host]
mail(to: @user.email, s... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/app/mailers/registration_mailer.rb | app/mailers/registration_mailer.rb | # author: Boris Barroso
# email: boriscyber@gmail.com
class RegistrationMailer < ActionMailer::Base
default from: %Q("#{APP_NAME}" <register@#{DOMAIN}>)
layout 'email'
# Sends the registration email to the contact
def send_registration(reg)
@user = reg.user
@tenant = reg.tenant
to = [@user.email]
... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/app/mailers/invoice_mailer.rb | app/mailers/invoice_mailer.rb | # encoding: utf-8
# author: Boris Barroso
# email: boriscyber@gmail.com
class InvoiceMailer < ActionMailer::Base
default from: "#{APP_NAME} <noresponder@bonsaierp.com>"
layout "email"
# Sends the invoice docment to the contact
def send_invoice(transaction, options)
@transaction = transaction
@message ... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/seeds.rb | db/seeds.rb | # encoding:utf-8
# Used to create sample data
=begin
user = User.new_user('demo@example.com', 'demo123')
user.save!
user.confirm_token(user.confirmation_token)
UserSession.current_user = user
# Countries
YAML.load_file('db/defaults/countries.yml').each do |c|
OrgCountry.create!(c){|co| co.id = c['id'] }
end
puts "... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/sequel.rb | db/sequel.rb | # HSTORE install
# gem install sequel
# gem install sequel-hstore
require 'sequel'
require 'sequel-hstore'
| ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/compare.rb | db/compare.rb | require 'sequel'
require 'benchmark'
require 'ffaker'
# adapter://user:password@host/database
DB = Sequel.connect('postgres://demo:demo123@localhost/test')
# Create all data
sql = "CREATE table names (name_btree text, name_gin text)"
DB.execute sql
sql = "CREATE EXTENSION pg_trgm"
DB.execute sql
sql = "CREATE INDEX in... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/schema.rb | db/schema.rb | # 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 sou... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20131224080916_add_accounts_hstore_extras.rb | db/migrate/20131224080916_add_accounts_hstore_extras.rb | class AddAccountsHstoreExtras < ActiveRecord::Migration
def up
PgTools.change_schema 'public'
PgTools.all_schemas.each do |schema|
next if schema == 'common'
execute "ALTER TABLE #{schema}.accounts ADD COLUMN extras public.hstore"
end
end
def down
PgTools.all_schemas.each do |schema|... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20130204171801_add_tenant_to_links.rb | db/migrate/20130204171801_add_tenant_to_links.rb | class AddTenantToLinks < ActiveRecord::Migration
def up
PgTools.with_schemas only: ['common', 'public'] do
change_table :links do |t|
t.string :tenant, limit: 100
end
add_index :links, :tenant
Link.connection.execute("UPDATE common.links AS l SET tenant=o.tenant FROM common.organ... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20100416193705_create_units.rb | db/migrate/20100416193705_create_units.rb | class CreateUnits < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
create_table :units do |t|
t.string :name, :limit => 100
t.string :symbol, :limit => 20
t.boolean :integer, :default => false
t.boolean :visible, :default => true
t.timestamps... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20130325155351_add_items_buy_price.rb | db/migrate/20130325155351_add_items_buy_price.rb | class AddItemsBuyPrice < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
change_table :items do |t|
t.decimal :buy_price, precision: 14, scale: 2, default: 0.0
end
end
end
def down
PgTools.with_schemas except: 'common' do
change_table :items do |t|
... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20130114144400_create_transactions.rb | db/migrate/20130114144400_create_transactions.rb | class CreateTransactions < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
create_table :transactions do |t|
t.integer :account_id
# Use Account#amount for total, create alias
t.decimal :total, precision: 14, scale: 2, default: 0.0
# Use Account#nam... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20130510144731_remove_state_from_inventory_operations.rb | db/migrate/20130510144731_remove_state_from_inventory_operations.rb | class RemoveStateFromInventoryOperations < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
remove_column :inventory_operations, :state
end
end
def down
end
end
| ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20140219170720_change_accounts_description.rb | db/migrate/20140219170720_change_accounts_description.rb | class ChangeAccountsDescription < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
change_column :accounts, :description, :text
add_index :accounts, :description
end
end
def down
PgTools.with_schemas except: 'common' do
change_column :accounts, :description, :... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20100427190727_create_contacts.rb | db/migrate/20100427190727_create_contacts.rb | class CreateContacts < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
create_table :contacts do |t|
t.string :matchcode
t.string :first_name, limit: 100
t.string :last_name, limit: 100
t.string :organisation_name, limit: 100
t.string :address... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20100325221629_create_organisations.rb | db/migrate/20100325221629_create_organisations.rb | class CreateOrganisations < ActiveRecord::Migration
def up
PgTools.with_schemas only: ['common', 'public'] do
create_table :organisations do |t|
t.integer :country_id
t.string :name, limit: 100
t.string :address
t.string :address_alt
t.string :phone , limit: 2... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20131009131456_create_taxes.rb | db/migrate/20131009131456_create_taxes.rb | class CreateTaxes < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
create_table :taxes do |t|
t.string :name, limit: 100
t.string :abreviation, limit: 20
t.decimal :percentage, precision: 5, scale: 2, default: 0.0
t.timestamps
end
end
end... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20110119140408_create_projects.rb | db/migrate/20110119140408_create_projects.rb | class CreateProjects < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
create_table :projects do |t|
t.string :name
t.boolean :active, :default => true
t.date :date_start
t.date :date_end
t.text :description
t.timestamps
end
... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20130411141221_add_incomes_expenses_status_on_contacts.rb | db/migrate/20130411141221_add_incomes_expenses_status_on_contacts.rb | class AddIncomesExpensesStatusOnContacts < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
change_table :contacts do |t|
t.remove :money_status
t.string :incomes_status, default: '{}', limit: 300
t.string :expenses_status, default: '{}', limit: 300
end
... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20160602111033_add_users_locale.rb | db/migrate/20160602111033_add_users_locale.rb | class AddUsersLocale < ActiveRecord::Migration
def change
PgTools.with_schemas only: ["common", "public"] do
add_column :users, :locale, :string, default: "en"
end
end
end
| ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20141112132422_add_account_name_unique_index.rb | db/migrate/20141112132422_add_account_name_unique_index.rb | class AddAccountNameUniqueIndex < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
remove_index :accounts, :name
end
PgTools.with_schemas except: 'common' do
add_index :accounts, :name, unique: true
end
end
def down
PgTools.with_schemas except: 'common' do
... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20160211130733_set_organisation_settings_jsonb.rb | db/migrate/20160211130733_set_organisation_settings_jsonb.rb | class SetOrganisationSettingsJsonb < ActiveRecord::Migration
def up
PgTools.with_schemas only: 'common' do
change_column :organisations, :settings, :hstore, :default => nil
end
end
def down
PgTools.with_schemas only: 'common' do
change_column :organisations, :settings, :hstore, :default =... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20140603135208_add_links_api_token.rb | db/migrate/20140603135208_add_links_api_token.rb | class AddLinksApiToken < ActiveRecord::Migration
def up
PgTools.with_schemas only: ['common', 'public'] do
add_column :links, :api_token, :string
add_index :links, :api_token, unique: true
end
end
def down
PgTools.with_schemas only: ['common', 'public'] do
remove_index :links, :api_... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20131009141203_add_accounts_tax_id.rb | db/migrate/20131009141203_add_accounts_tax_id.rb | class AddAccountsTaxId < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
change_table :accounts do |t|
t.decimal :tax_percentage, precision: 5, scale: 2, default: 0
t.integer :tax_id
end
add_index :accounts, :tax_id
end
end
def down
PgTools.w... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20140925003650_add_attachments_publish.rb | db/migrate/20140925003650_add_attachments_publish.rb | class AddAttachmentsPublish < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
add_column :attachments, :publish, :boolean, default: false
add_index :attachments, :publish
end
end
def down
PgTools.with_schemas except: 'common' do
remove_index :attachments, :pu... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20140704132611_create_tag_groups.rb | db/migrate/20140704132611_create_tag_groups.rb | class CreateTagGroups < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
create_table :tag_groups do |t|
t.string :name
t.string :bgcolor
t.integer :tag_ids, integer: true, array: true, default: []
t.timestamps
end
add_index :tag_groups, :... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20131224080216_add_hstore.rb | db/migrate/20131224080216_add_hstore.rb | class AddHstore < ActiveRecord::Migration
def up
execute "CREATE EXTENSION IF NOT EXISTS hstore SCHEMA public"
end
def down
execute 'DROP EXTENSION IF EXISTS hstore'
end
end
| ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20140215130814_add_organisations_settings.rb | db/migrate/20140215130814_add_organisations_settings.rb | class AddOrganisationsSettings < ActiveRecord::Migration
def up
PgTools.with_schemas %w(public common) do
change_table :organisations do |t|
t.hstore :settings
end
change_column_default :organisations, :settings, inventory: true
end
end
def down
PgTools.with_schemas %w(publi... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20140105165519_add_account_ledgers_contact_id.rb | db/migrate/20140105165519_add_account_ledgers_contact_id.rb | class AddAccountLedgersContactId < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
change_table :account_ledgers do |t|
t.integer :contact_id
t.index :contact_id
end
execute 'UPDATE account_ledgers al SET contact_id = a.contact_id FROM accounts a WHERE al... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20130429120114_remove_banks_number.rb | db/migrate/20130429120114_remove_banks_number.rb | class RemoveBanksNumber < ActiveRecord::Migration
def up
Organisation.pluck(:tenant).each do |tenant|
if PgTools.schema_exists? tenant
Bank.includes(:money_store).each {|b| b.update_attributes!(name: "#{bank.name.strip} #{bank.number.strip}") }
end
end
PgTools.with_schemas except: 'co... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20100101101010_create_schema_common.rb | db/migrate/20100101101010_create_schema_common.rb | class CreateSchemaCommon < ActiveRecord::Migration
def up
PgTools.create_schema 'common' unless PgTools.schema_exists?('common')
end
def down
PgTools.drop_schema 'common'
end
end
| ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20130618172158_add_accounts_tags.rb | db/migrate/20130618172158_add_accounts_tags.rb | class AddAccountsTags < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
add_column :accounts, :tag_ids, :integer, array: true, default: []
add_index :accounts, :tag_ids, using: 'gin'
end
end
def down
PgTools.with_schemas except: 'common' do
remove_index :acco... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20140213135130_add_creator_id_to_items.rb | db/migrate/20140213135130_add_creator_id_to_items.rb | class AddCreatorIdToItems < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
change_table :items do |t|
t.integer :creator_id
t.index :creator_id
end
end
end
def down
PgTools.with_schemas except: 'common' do
remove_index :items, :creator_id
... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20140127025407_remove_user_changes.rb | db/migrate/20140127025407_remove_user_changes.rb | class RemoveUserChanges < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
drop_table :user_changes
drop_table :money_stores
drop_table :transaction_histories
end
end
end
| ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20100531141109_create_stores.rb | db/migrate/20100531141109_create_stores.rb | class CreateStores < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
create_table :stores do |t|
t.string :name
t.string :address
t.string :phone
t.boolean :active, :default => true
t.string :description
t.timestamps
end
end
... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20140217134723_drop_transactions_table.rb | db/migrate/20140217134723_drop_transactions_table.rb | class DropTransactionsTable < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
drop_table :transactions
end
end
def down
puts 'Nothing to do with table transactions'
end
end
| ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20160215135420_convert_accounts_extras_hstore_to_jsonb.rb | db/migrate/20160215135420_convert_accounts_extras_hstore_to_jsonb.rb | class ConvertAccountsExtrasHstoreToJsonb < ActiveRecord::Migration
def up
PgTools.with_schemas except: "common" do
execute("ALTER TABLE accounts ALTER COLUMN extras TYPE JSONB USING CAST(extras as JSONB);")
add_index :accounts, :extras, using: "gin"
end
end
end
| ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20140219210139_add_pg_trgm_extension.rb | db/migrate/20140219210139_add_pg_trgm_extension.rb | class AddPgTrgmExtension < ActiveRecord::Migration
def up
execute 'CREATE EXTENSION IF NOT EXISTS pg_trgm SCHEMA public'
end
def down
execute 'DROP EXTENSION pg_trgm'
end
end
| ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20130426151609_remove_active_conciliation_from_account_ledgers.rb | db/migrate/20130426151609_remove_active_conciliation_from_account_ledgers.rb | class RemoveActiveConciliationFromAccountLedgers < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
change_table :account_ledgers do |t|
t.remove :conciliation
t.remove :active
end
end
end
def down
end
end
| ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20130704130428_add_transactions_no_inventory.rb | db/migrate/20130704130428_add_transactions_no_inventory.rb | class AddTransactionsNoInventory < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
change_table :transactions do |t|
t.boolean :no_inventory, default: false
end
add_index :transactions, :no_inventory
end
end
def down
PgTools.with_schemas except: 'com... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20111103143524_create_transaction_histories.rb | db/migrate/20111103143524_create_transaction_histories.rb | class CreateTransactionHistories < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
create_table :transaction_histories do |t|
t.integer :account_id
t.integer :user_id
t.text :data
t.timestamps
end
add_index :transaction_histories, :acc... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20100401192000_create_links.rb | db/migrate/20100401192000_create_links.rb | class CreateLinks < ActiveRecord::Migration
def up
PgTools.with_schemas only: ['common', 'public'] do
create_table :links do |t|
t.integer :organisation_id
t.integer :user_id
t.string :settings
t.boolean :creator , default: false
t.boolean :master_account , de... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20140205123754_add_history_extra_fields.rb | db/migrate/20140205123754_add_history_extra_fields.rb | class AddHistoryExtraFields < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
change_table :histories do |t|
t.hstore :extras
t.text :all_data
end
end
end
def down
PgTools.with_schemas except: 'common' do
change_table :histories do |t|
... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20100421174307_create_items.rb | db/migrate/20100421174307_create_items.rb | class CreateItems < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
create_table :items do |t|
t.integer :unit_id
t.decimal :price, precision: 14, scale: 2, default: 0.0
t.string :name
t.string :description
t.string :code, :limit => 100
... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20141028104251_add_organisation_due_on_and_plan.rb | db/migrate/20141028104251_add_organisation_due_on_and_plan.rb | class AddOrganisationDueOnAndPlan < ActiveRecord::Migration
def up
PgTools.with_schemas only: 'common' do
add_column :organisations, :due_on, :date
add_column :organisations, :plan, :string, default: '2users'
end
end
def down
PgTools.with_schemas only: 'common' do
remove_column :org... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20130911005608_change_phone_number_lenght.rb | db/migrate/20130911005608_change_phone_number_lenght.rb | class ChangePhoneNumberLenght < ActiveRecord::Migration
def up
PgTools.with_schemas only: ['common', 'public'] do
change_column :organisations, :phone, :string, limit: 40
change_column :organisations, :phone_alt, :string, limit: 40
change_column :organisations, :mobile, :string, limit: 40
... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20130702144114_add_tables_updater_id.rb | db/migrate/20130702144114_add_tables_updater_id.rb | class AddTablesUpdaterId < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
add_column :account_ledgers, :updater_id, :integer
add_index :account_ledgers, :updater_id
add_column :accounts, :updater_id, :integer
add_index :accounts, :updater_id
add_column :inven... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20131221130149_add_account_ledgers_name.rb | db/migrate/20131221130149_add_account_ledgers_name.rb | class AddAccountLedgersName < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
change_column :account_ledgers, :date, :date
change_table :account_ledgers do |t|
t.string :name
t.index :name, unique: true
end
execute("UPDATE account_ledgers SET name =... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20140131140212_rename_link_rol_to_role.rb | db/migrate/20140131140212_rename_link_rol_to_role.rb | class RenameLinkRolToRole < ActiveRecord::Migration
def up
PgTools.with_schemas only: ['common', 'public'] do
rename_column :links, :rol, :role
end
end
def down
PgTools.with_schemas only: ['common', 'public'] do
rename_column :links, :role, :rol
end
end
end
| ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20110201153434_create_accounts.rb | db/migrate/20110201153434_create_accounts.rb | class CreateAccounts < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
create_table :accounts do |t|
t.string :name
t.string :currency, limit: 10
t.decimal :exchange_rate, precision: 14, scale: 4, default: 1.0
t.decimal :amount, precision: 14, scale:... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20110411182005_create_inventory_operations.rb | db/migrate/20110411182005_create_inventory_operations.rb | class CreateInventoryOperations < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
create_table :inventory_operations do |t|
t.integer :contact_id
t.integer :store_id
t.integer :account_id
t.date :date
t.string :ref_number
t.string :... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20110201161907_create_account_ledgers.rb | db/migrate/20110201161907_create_account_ledgers.rb | class CreateAccountLedgers < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
create_table :account_ledgers do |t|
t.string :reference
t.string :currency
t.integer :account_id
t.decimal :account_balance, precision: 14, scale: 2, default: 0.0
... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20140417145820_change_histories_to_json.rb | db/migrate/20140417145820_change_histories_to_json.rb | class ChangeHistoriesToJson < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
#change_column :histories, :history_data, :json
execute("ALTER TABLE histories ALTER COLUMN history_data TYPE json USING history_data::json")
execute("ALTER TABLE histories ALTER COLUMN history_... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20130114164401_create_transaction_details.rb | db/migrate/20130114164401_create_transaction_details.rb | class CreateTransactionDetails < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
create_table :transaction_details do |t|
t.integer :account_id
t.integer :item_id
t.decimal :quantity, :precision => 14, :scale => 2, default: 0.0
t.decimal :price, :prec... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20130527202406_add_items_unit_code.rb | db/migrate/20130527202406_add_items_unit_code.rb | class AddItemsUnitCode < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
change_table :items do |t|
t.string :unit_symbol, limit: 20
t.string :unit_name, limit: 255
end
change_column :items, :name, :string, limit: 255
end
end
def down
PgTools... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20130115020409_create_money_stores.rb | db/migrate/20130115020409_create_money_stores.rb | class CreateMoneyStores < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
create_table :money_stores do |t|
t.integer :account_id
t.string :number, limit: 100
t.string :email
t.string :address, limit: 300
t.string :phone, limit: 50
... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20130522125737_rename_inventory_operations.rb | db/migrate/20130522125737_rename_inventory_operations.rb | class RenameInventoryOperations < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
remove_index :inventory_operation_details, :inventory_operation_id
rename_table :inventory_operations, :inventories
rename_table :inventory_operation_details, :inventory_details
rena... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20131227032328_update_incomes_expenses_hstore_transactions.rb | db/migrate/20131227032328_update_incomes_expenses_hstore_transactions.rb | class UpdateIncomesExpensesHstoreTransactions < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
execute <<-SQL
UPDATE accounts a SET extras = HSTORE('bill_number', t.bill_number) ||
HSTORE('gross_total', t.gross_total::text) ||
HSTORE('original_total', t.original_total::text) ||
HSTO... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20140227163833_add_contacts_tag_ids.rb | db/migrate/20140227163833_add_contacts_tag_ids.rb | class AddContactsTagIds < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
add_column :contacts, :tag_ids, :integer, array: true, default: []
add_index :contacts, :tag_ids, using: 'gin'
end
end
def down
PgTools.with_schemas except: 'common' do
remove_index :co... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20140219210551_add_gin_idexes_accounts_account_ledgers.rb | db/migrate/20140219210551_add_gin_idexes_accounts_account_ledgers.rb | class AddGinIdexesAccountsAccountLedgers < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
# account_ledgers
remove_column :account_ledgers, :description
remove_column :account_ledgers, :old_reference
remove_index :account_ledgers, :reference
change_column :ac... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20130715185912_add_organisations_active_inventory.rb | db/migrate/20130715185912_add_organisations_active_inventory.rb | class AddOrganisationsActiveInventory < ActiveRecord::Migration
def up
PgTools.with_schemas only: 'common' do
change_table :organisations do |t|
t.boolean :inventory_active, default: true
end
end
end
def down
PgTools.with_schemas only: 'common' do
change_table :organisations... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20131224081504_add_accounts_creator_approver_updater.rb | db/migrate/20131224081504_add_accounts_creator_approver_updater.rb | class AddAccountsCreatorApproverUpdater < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do |t|
change_table :accounts do |t|
t.integer :creator_id
t.integer :approver_id
t.integer :nuller_id
t.date :due_date
end
add_index :accounts, :creato... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20140129135140_add_histories_klass_type.rb | db/migrate/20140129135140_add_histories_klass_type.rb | class AddHistoriesKlassType < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
add_column :histories, :klass_type, :string
end
end
def down
PgTools.with_schemas except: 'common' do
remove_column :histories, :klass_type
end
end
end
| ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20131227025934_update_money_store_to_hstore.rb | db/migrate/20131227025934_update_money_store_to_hstore.rb | class UpdateMoneyStoreToHstore < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
# Bank
execute <<-SQL
UPDATE accounts a SET extras = HSTORE('email', ms.email) || HSTORE('address', ms.address) || HSTORE('phone', ms.phone) || HSTORE('website', ms.website) FROM money_stores ms
WH... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20140127023427_rename_transaction_details.rb | db/migrate/20140127023427_rename_transaction_details.rb | class RenameTransactionDetails < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
rename_table :transaction_details, :movement_details
end
end
def down
PgTools.with_schemas except: 'common' do
rename_table :movement_details, :transaction_details
end
end
end
| ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20130716131229_add_tags_to_items.rb | db/migrate/20130716131229_add_tags_to_items.rb | class AddTagsToItems < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
change_table :items do |t|
t.integer :tag_ids, array: true, default: []
end
#execute "ALTER TABLE items ADD COLUMN tag_ids integer[] DEFAULT '{}'"
execute "CREATE INDEX index_items_on_ta... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20140118184207_create_histories.rb | db/migrate/20140118184207_create_histories.rb | class CreateHistories < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
create_table :histories do |t|
t.integer :user_id
t.integer :historiable_id
t.boolean :new_item, default: false
t.string :historiable_type
t.text :history_data
t.d... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20130717190543_add_account_ledgers_old_reference.rb | db/migrate/20130717190543_add_account_ledgers_old_reference.rb | class AddAccountLedgersOldReference < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
change_table :account_ledgers do |t|
t.string :old_reference
end
end
end
def down
PgTools.with_schemas except: 'common' do
change_table :account_ledgers do |t|
... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20160215132803_convert_org_settings_to_json.rb | db/migrate/20160215132803_convert_org_settings_to_json.rb | class ConvertOrgSettingsToJson < ActiveRecord::Migration
def up
execute("ALTER TABLE common.organisations ALTER COLUMN settings TYPE JSONB USING CAST(settings as JSONB);")
end
def down
end
end
| ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20140730171947_create_array_intersection.rb | db/migrate/20140730171947_create_array_intersection.rb | class CreateArrayIntersection < ActiveRecord::Migration
def up
execute <<-SQL
CREATE OR REPLACE FUNCTION public.array_intersection(anyarray, anyarray)
RETURNS anyarray AS
$BODY$
SELECT ARRAY(
SELECT $1[i]
FROM generate_series( array_lower($1, 1), array_upper($1, 1) ) i
WHERE ARRAY[$1[i]] && $2
);
$B... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20121215153208_create_user_changes.rb | db/migrate/20121215153208_create_user_changes.rb | class CreateUserChanges < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
create_table :user_changes do |t|
t.string :name
t.integer :user_id
t.string :user_changeable_type
t.integer :user_changeable_id
t.text :description
t.timestamp... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20160215133105_remove_index_accounts_extras.rb | db/migrate/20160215133105_remove_index_accounts_extras.rb | class RemoveIndexAccountsExtras < ActiveRecord::Migration
def up
PgTools.with_schemas except: "common" do
remove_index :accounts, :extras
end
end
def down
end
end
| ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20110411174426_create_stocks.rb | db/migrate/20110411174426_create_stocks.rb | class CreateStocks < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
create_table :stocks do |t|
t.integer :store_id
t.integer :item_id
t.string :state, :limit => 20
t.decimal :unitary_cost, :precision => 14, :scale => 2, default: 0.0
t.decima... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20130618184031_create_tags.rb | db/migrate/20130618184031_create_tags.rb | class CreateTags < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
create_table :tags do |t|
t.string :name
t.string :bgcolor, limit: 10
t.timestamps
end
add_index :tags, :name
end
end
end
| ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20110411182905_create_inventory_operation_details.rb | db/migrate/20110411182905_create_inventory_operation_details.rb | class CreateInventoryOperationDetails < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
create_table :inventory_operation_details do |t|
t.integer :inventory_operation_id
t.integer :item_id
t.integer :store_id
t.decimal :quantity, :precision => 14, :s... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20131223155017_add_accounts_tax_in_out.rb | db/migrate/20131223155017_add_accounts_tax_in_out.rb | class AddAccountsTaxInOut < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
change_table :accounts do |t|
t.boolean :tax_in_out, default: false
end
add_index :accounts, :tax_in_out # Needs onserver index
end
end
end
| ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20100324202441_create_users.rb | db/migrate/20100324202441_create_users.rb | # encoding: utf-8
# author: Boris Barroso
# email: boriscyber@gmail.com
class CreateUsers < ActiveRecord::Migration
def up
PgTools.with_schemas only: ['common','public'] do
create_table :users do |t|
# user
t.string :email, null: false
t.string :first_name, :limit => 80
t.str... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20130510222719_change_stock_active_column.rb | db/migrate/20130510222719_change_stock_active_column.rb | class ChangeStockActiveColumn < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
change_table :stocks do |t|
t.boolean :active, default: true
t.remove :state
# Index
t.index :active
end
end
end
def down
PgTools.with_schemas except: '... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20140423120216_change_histories_all_data_hstore.rb | db/migrate/20140423120216_change_histories_all_data_hstore.rb | class ChangeHistoriesAllDataHstore < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
#change_column :histories, :history_data, :json
execute("ALTER TABLE histories ALTER COLUMN all_data TYPE json USING all_data::json")
execute("ALTER TABLE histories ALTER COLUMN all_data ... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
bonsaiERP/bonsaiERP | https://github.com/bonsaiERP/bonsaiERP/blob/0edb91af594f81e7534dbc90525a406c645ad164/db/migrate/20131211134555_add_accounts_total.rb | db/migrate/20131211134555_add_accounts_total.rb | class AddAccountsTotal < ActiveRecord::Migration
def up
PgTools.with_schemas except: 'common' do
# Add to accounts
add_column :accounts, :total, :decimal, precision: 14, scale: 2, default: 0
# Updates
execute("UPDATE accounts a SET total = t.total FROM transactions t WHERE (t.account_id =... | ruby | MIT | 0edb91af594f81e7534dbc90525a406c645ad164 | 2026-01-04T17:40:51.865869Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.