diff --git a/config/application.rb b/config/application.rb index 2cc92e8e..579177e0 100644 --- a/config/application.rb +++ b/config/application.rb @@ -19,13 +19,18 @@ require 'rails/test_unit/railtie' Bundler.require(*Rails.groups) module Sutty + # Sutty! class Application < Rails::Application - # Initialize configuration defaults for originally generated Rails version. + # Initialize configuration defaults for originally generated Rails + # version. config.load_defaults 5.1 - # Settings in config/environments/* take precedence over those specified here. - # Application configuration should go into files in config/initializers - # -- all .rb files in that directory are automatically loaded. - config.action_dispatch.rescue_responses['Pundit::NotAuthorizedError'] = :forbidden + # Settings in config/environments/* take precedence over those + # specified here. Application configuration should go into files in + # config/initializers -- all .rb files in that directory are + # automatically loaded. + config.action_dispatch + .rescue_responses['Pundit::NotAuthorizedError'] = :forbidden + config.active_record.sqlite3.represent_boolean_as_integer = true end end diff --git a/db/migrate/20190703200455_create_sitios.rb b/db/migrate/20190703200455_create_sitios.rb index c8e45d34..7f8ae8fc 100644 --- a/db/migrate/20190703200455_create_sitios.rb +++ b/db/migrate/20190703200455_create_sitios.rb @@ -44,7 +44,10 @@ class CreateSitios < ActiveRecord::Migration[5.2] usuarie ||= Usuarie.create(email: email, password: SecureRandom.hex, confirmed_at: Date.today) - site.usuaries << usuarie + + sql = "insert into sites_usuaries (site_id, usuarie_id) + values (#{site.id}, #{usuarie.id});" + ActiveRecord::Base.connection.execute(sql) end invitadxs.each do |email| @@ -52,7 +55,9 @@ class CreateSitios < ActiveRecord::Migration[5.2] usuarie ||= Usuarie.create(email: email, password: SecureRandom.hex, confirmed_at: Date.today) - site.invitades << usuarie + sql = "insert into invitades_sites (site_id, usuarie_id) + values (#{site.id}, #{usuarie.id});" + ActiveRecord::Base.connection.execute(sql) end end end diff --git a/db/migrate/20190712165059_sqlite_boolean.rb b/db/migrate/20190712165059_sqlite_boolean.rb new file mode 100644 index 00000000..7f41afd8 --- /dev/null +++ b/db/migrate/20190712165059_sqlite_boolean.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +# Convertir los valores binarios de sqlite +class SqliteBoolean < ActiveRecord::Migration[5.2] + def up + return unless adapter_name == 'SQLite' + + Usuarie.where("acepta_politicas_de_privacidad = 't'") + .update_all(acepta_politicas_de_privacidad: 1) + Usuarie.where("acepta_politicas_de_privacidad = 'f'") + .update_all(acepta_politicas_de_privacidad: 0) + + change_column :usuaries, :acepta_politicas_de_privacidad, :boolean, + default: 0 + end + + def down + return unless adapter_name == 'SQLite' + + Usuarie.where('acepta_politicas_de_privacidad = 1') + .update_all(acepta_politicas_de_privacidad: 't') + Usuarie.where('acepta_politicas_de_privacidad = 0') + .update_all(acepta_politicas_de_privacidad: 'f') + + change_column :usuaries, :acepta_politicas_de_privacidad, :boolean, + default: 'f' + end +end diff --git a/db/schema.rb b/db/schema.rb index c01df6a3..98e398c9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -12,7 +12,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20_190_711_183_726) do +ActiveRecord::Schema.define(version: 20_190_712_165_059) do create_table 'roles', force: :cascade do |t| t.datetime 'created_at', null: false t.datetime 'updated_at', null: false