Commit ed1c503d authored by mateus ravedutti's avatar mateus ravedutti

Fix migrations pattern and keys

parent 374ee3fa
Pipeline #7154 failed with stage
in 9 seconds
......@@ -2,7 +2,7 @@ class DeviseTokenAuthCreateAccounts < ActiveRecord::Migration
def change
create_table(:accounts) do |t|
## Database authenticatable
t.string :encrypted_password, :null => false, :default => ""
t.string :encrypted_password, null: false, default: ""
## Recoverable
t.string :reset_password_token
......@@ -12,14 +12,14 @@ class DeviseTokenAuthCreateAccounts < ActiveRecord::Migration
t.datetime :remember_created_at
## Trackable
t.integer :sign_in_count, :default => 0, :null => false
t.integer :sign_in_count, default: 0, null: false
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
t.string :last_sign_in_ip
t.string :provider, :null => false, :default => "cpf"
t.string :uid, :null => false, :default => ""
t.string :provider, null: false, default: "cpf"
t.string :uid, null: false, default: ""
## Tokens
t.json :tokens
......@@ -27,7 +27,7 @@ class DeviseTokenAuthCreateAccounts < ActiveRecord::Migration
t.timestamps
end
add_index :accounts, :uid, :unique => true
add_index :accounts, :reset_password_token, :unique => true
add_index :accounts, :uid, unique: true
add_index :accounts, :reset_password_token, unique: true
end
end
class CreateCitizens < ActiveRecord::Migration[5.0]
def change
create_table :citizens do |t|
t.date :birth_date
t.string :name
t.string :rg
t.date :birth_date, null: false
t.string :name, null: false
t.string :rg, null: false
t.string :address_complement
t.string :address_number
t.string :address_street
......
class AddAccountToCitizens < ActiveRecord::Migration[5.0]
def change
add_reference :citizens, :account, foreign_key: true
add_reference :citizens, :account, foreign_key: true, index: true
end
end
......@@ -2,9 +2,9 @@ class CreateProfessionals < ActiveRecord::Migration[5.0]
def change
create_table :professionals do |t|
t.string :registration
t.boolean :active, :null => false, :default => true
t.boolean :active, null: false, default: true
t.timestamps
t.references :account
t.references :account, foreign_key: true, index: true
end
end
end
class AddActiveToCitizens < ActiveRecord::Migration[5.0]
def change
add_column :citizens, :active, :boolean
add_column :citizens, :active, :boolean, null: false
end
end
class CreateServicePlaces < ActiveRecord::Migration[5.0]
def change
create_table :service_places do |t|
t.string :name, :null => false
t.string :cep, :limit => 10
t.string :neighborhood, :null => false
t.string :address_street, :null => false
t.string :address_number, :null => false, :limit => 10
t.string :name, null: false
t.string :cep, limit: 10
t.string :neighborhood, null: false
t.string :address_street, null: false
t.string :address_number, null: false, limit: 10
t.string :address_complement
t.string :phone1, :limit => 13
t.string :phone2, :limit => 13
t.string :phone1, limit: 13
t.string :phone2, limit: 13
t.string :email
t.string :url
t.boolean :active, :null => false, :default => true
t.boolean :active, null: false, default: true
t.timestamps
end
end
......
class CreateJoinTableProfessionalsServicePlaces < ActiveRecord::Migration[5.0]
def change
create_join_table :professionals, :service_places do |t|
t.string :role, :null => false
t.boolean :active, :null => false, :default => true
# t.index [:professional_id, :service_place_id]
# t.index [:service_place_id, :professional_id]
t.string :role, null: false
t.boolean :active, null: false, default: true
t.index [:professional_id, :service_place_id], name: "idx_professional_service_place"
t.index [:service_place_id, :professional_id], name: "idx_service_place_professional"
end
end
end
class CreateJoinTableAccountsServicePlaces < ActiveRecord::Migration[5.0]
def change
create_join_table :accounts, :service_places do |t|
# t.index [:account_id, :service_place_id]
# t.index [:service_place_id, :account_id]
t.index [:account_id, :service_place_id], name: "idx_accounts_service_places"
t.index [:service_place_id, :account_id], name: "idx_service_places_accounts"
end
end
end
class CreateCityHalls < ActiveRecord::Migration[5.0]
def change
create_table :city_halls do |t|
t.integer :city_id
t.boolean :active
t.integer :city_id, null: false
t.boolean :active, null: false
t.string :address_number, null: false, limit: 10
t.string :address_street, null: false
t.text :block_text, null: false
......
class AddCityRefToCityHall < ActiveRecord::Migration[5.0]
def change
add_reference :city_halls, :city, foreign_key: true
add_reference :city_halls, :city, foreign_key: true, indeX: true, null: false
end
end
class AddStateRefToCity < ActiveRecord::Migration[5.0]
def change
add_reference :cities, :state, foreign_key: true
add_reference :cities, :state, foreign_key: true, index: true, null: false
end
end
class AddCityHallToServicePlaces < ActiveRecord::Migration[5.0]
def change
add_reference :service_places, :city_hall, index: true
add_reference :service_places, :city_hall, foreign_key: true, index: true, null: false
end
end
class CreateDependants < ActiveRecord::Migration[5.0]
def change
create_table :dependants do |t|
t.boolean :active, :null => false, :default => true
t.boolean :active, :default => true
t.datetime :deactivated
t.references :citizen, index: true
t.references :citizen, foreign_key: true, index: true, null: false
t.timestamps
end
end
......
......@@ -4,7 +4,7 @@ class CreateOccupations < ActiveRecord::Migration[5.0]
t.string :description
t.string :name
t.boolean :active
t.references :city_hall, foreign_key: true
t.references :city_hall, foreign_key: true, index: true, null: false
t.timestamps
end
......
class AddOccupationRefToProfessionals < ActiveRecord::Migration[5.0]
def change
add_reference :professionals, :occupation, foreign_key: true
add_reference :professionals, :occupation, foreign_key: true, index: true, null: false
end
end
class CreateBlocks < ActiveRecord::Migration[5.0]
def change
create_table :blocks do |t|
t.references :account ,index:true, null: false
t.references :dependant, index: true
t.references :account ,index: true, foreign_key: true, null: false
t.references :dependant, index: true, foreign_key: true
t.date :block_begin
t.date :block_end
end
......
class CreateSectors < ActiveRecord::Migration[5.0]
def change
create_table :sectors do |t|
t.references :city_hall, index: true, null: false
t.references :city_hall, index: true, foreign_key: true, null: false
t.boolean :active
t.integer :absence_max
t.integer :blocking_days
......
class AddSectorToBlocks < ActiveRecord::Migration[5.0]
def change
add_reference :blocks, :sector, index: true, null: false
add_reference :blocks, :sector, index: true, foreign_key: true, null: false
end
end
class CreateServiceTypes < ActiveRecord::Migration[5.0]
def change
create_table :service_types do |t|
t.references :sector, index: true, null: false
t.references :sector, index: true, foreign_key: true, null: false
t.boolean :active
t.text :description
t.timestamps
......
class CreateJoinTableServiceTypesServicePlaces < ActiveRecord::Migration[5.0]
def change
create_join_table :service_types, :service_places do |t|
# t.index [:service_type_id, :service_place_id]
# t.index [:service_place_id, :service_type_id]
t.index [:service_type_id, :service_place_id], name: "idx_service_type_service_place"
t.index [:service_place_id, :service_type_id], name: "idx_service_place_service_type"
end
end
end
class CreateShifts < ActiveRecord::Migration[5.0]
def change
create_table :shifts do |t|
t.references :service_place, index: true, null: false
t.references :service_type, index: true, null: false
t.references :service_place, foreign_key: true, index: true, null: false
t.references :service_type, foreign_key: true, index: true, null: false
t.integer :next_shift_id
t.integer :professional_performer_id
t.integer :professional_responsible_id
......
class CreateSituations < ActiveRecord::Migration[5.0]
def change
create_table :situations do |t|
t.string :description
t.string :description, null: false
t.timestamps
end
end
......
class CreateSchedules < ActiveRecord::Migration[5.0]
def change
create_table :schedules do |t|
t.references :shift, index: true, null: false
t.references :situation, index: true, null: false
t.references :service_place, index: true, null: false
t.references :account, index: true
t.references :shift, foreign_key: true, index: true, null: false
t.references :situation, foreign_key: true, index: true, null: false
t.references :service_place, foreign_key: true, index: true, null: false
t.references :account, foreign_key: true, index: true
t.integer :citizen_ajax_read, null: false
t.integer :professional_ajax_read, null: false
t.integer :reminder_read, null: false
......
class CreateSolicitations < ActiveRecord::Migration[5.0]
def change
create_table :solicitations do |t|
t.references :city, foreign_key: true
t.string :name
t.string :cpf
t.string :email
t.references :city, foreign_key: true, index: true
t.string :name, null: false
t.string :cpf, null: false
t.string :email, null: false
t.string :cep
t.string :phone
t.boolean :sent
......
class AddCityToCitizens < ActiveRecord::Migration[5.0]
def change
add_reference :citizens, :city, foreign_key: true
add_reference :citizens, :city, foreign_key: true, index: true
end
end
......@@ -37,6 +37,8 @@ ActiveRecord::Schema.define(version: 20161007130605) do
create_table "accounts_service_places", id: false, force: :cascade do |t|
t.integer "account_id", null: false
t.integer "service_place_id", null: false
t.index ["account_id", "service_place_id"], name: "idx_accounts_service_places", using: :btree
t.index ["service_place_id", "account_id"], name: "idx_service_places_accounts", using: :btree
end
create_table "blocks", force: :cascade do |t|
......@@ -55,14 +57,14 @@ ActiveRecord::Schema.define(version: 20161007130605) do
t.string "name", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "state_id"
t.integer "state_id", null: false
t.index ["state_id"], name: "index_cities_on_state_id", using: :btree
end
create_table "citizens", force: :cascade do |t|
t.date "birth_date"
t.string "name"
t.string "rg"
t.date "birth_date", null: false
t.string "name", null: false
t.string "rg", null: false
t.string "address_complement"
t.string "address_number"
t.string "address_street"
......@@ -81,7 +83,7 @@ ActiveRecord::Schema.define(version: 20161007130605) do
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "account_id"
t.boolean "active"
t.boolean "active", null: false
t.integer "city_id"
t.integer "responsible_id"
t.index ["account_id"], name: "index_citizens_on_account_id", using: :btree
......@@ -89,7 +91,7 @@ ActiveRecord::Schema.define(version: 20161007130605) do
end
create_table "city_halls", force: :cascade do |t|
t.boolean "active"
t.boolean "active", null: false
t.string "address_number", limit: 10, null: false
t.string "address_street", null: false
t.text "block_text", null: false
......@@ -114,14 +116,14 @@ ActiveRecord::Schema.define(version: 20161007130605) do
t.string "url"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "city_id"
t.integer "city_id", null: false
t.index ["city_id"], name: "index_city_halls_on_city_id", using: :btree
end
create_table "dependants", force: :cascade do |t|
t.boolean "active", default: true, null: false
t.datetime "deactivated"
t.integer "citizen_id"
t.integer "citizen_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["citizen_id"], name: "index_dependants_on_citizen_id", using: :btree
......@@ -131,7 +133,7 @@ ActiveRecord::Schema.define(version: 20161007130605) do
t.string "description"
t.string "name"
t.boolean "active"
t.integer "city_hall_id"
t.integer "city_hall_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["city_hall_id"], name: "index_occupations_on_city_hall_id", using: :btree
......@@ -143,7 +145,7 @@ ActiveRecord::Schema.define(version: 20161007130605) do
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "account_id"
t.integer "occupation_id"
t.integer "occupation_id", null: false
t.index ["account_id"], name: "index_professionals_on_account_id", using: :btree
t.index ["occupation_id"], name: "index_professionals_on_occupation_id", using: :btree
end
......@@ -153,6 +155,8 @@ ActiveRecord::Schema.define(version: 20161007130605) do
t.integer "service_place_id", null: false
t.string "role", null: false
t.boolean "active", default: true, null: false
t.index ["professional_id", "service_place_id"], name: "idx_professional_service_place", using: :btree
t.index ["service_place_id", "professional_id"], name: "idx_service_place_professional", using: :btree
end
create_table "schedules", force: :cascade do |t|
......@@ -204,13 +208,15 @@ ActiveRecord::Schema.define(version: 20161007130605) do
t.boolean "active", default: true, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "city_hall_id"
t.integer "city_hall_id", null: false
t.index ["city_hall_id"], name: "index_service_places_on_city_hall_id", using: :btree
end
create_table "service_places_types", id: false, force: :cascade do |t|
t.integer "service_type_id", null: false
t.integer "service_place_id", null: false
t.index ["service_place_id", "service_type_id"], name: "idx_service_place_service_type", using: :btree
t.index ["service_type_id", "service_place_id"], name: "idx_service_type_service_place", using: :btree
end
create_table "service_types", force: :cascade do |t|
......@@ -239,16 +245,16 @@ ActiveRecord::Schema.define(version: 20161007130605) do
end
create_table "situations", force: :cascade do |t|
t.string "description"
t.string "description", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "solicitations", force: :cascade do |t|
t.integer "city_id"
t.string "name"
t.string "cpf"
t.string "email"
t.string "name", null: false
t.string "cpf", null: false
t.string "email", null: false
t.string "cep"
t.string "phone"
t.boolean "sent"
......@@ -265,11 +271,25 @@ ActiveRecord::Schema.define(version: 20161007130605) do
t.datetime "updated_at", null: false
end
add_foreign_key "blocks", "accounts"
add_foreign_key "blocks", "dependants"
add_foreign_key "blocks", "sectors"
add_foreign_key "cities", "states"
add_foreign_key "citizens", "accounts"
add_foreign_key "citizens", "cities"
add_foreign_key "city_halls", "cities"
add_foreign_key "dependants", "citizens"
add_foreign_key "occupations", "city_halls"
add_foreign_key "professionals", "accounts"
add_foreign_key "professionals", "occupations"
add_foreign_key "schedules", "accounts"
add_foreign_key "schedules", "service_places"
add_foreign_key "schedules", "shifts"
add_foreign_key "schedules", "situations"
add_foreign_key "sectors", "city_halls"
add_foreign_key "service_places", "city_halls"
add_foreign_key "service_types", "sectors"
add_foreign_key "shifts", "service_places"
add_foreign_key "shifts", "service_types"
add_foreign_key "solicitations", "cities"
end
......@@ -14,14 +14,15 @@ class Api::V1::DependantsControllerTest < ActionDispatch::IntegrationTest
state_id: @santa_catarina.id)
@joinville.save!
@citizen= Citizen.new(cpf: "10845922904",
birth_date: "18/04/1997",
cep: "1234567",
email: "test@example.com",
name: "Test Example",
phone1: "(12)1212-1212",
city_id: @joinville.id,
rg: "1234567")
@citizen= Citizen.new(active: true,
cpf: "10845922904",
birth_date: "18/04/1997",
cep: "1234567",
email: "test@example.com",
name: "Test Example",
phone1: "(12)1212-1212",
city_id: @joinville.id,
rg: "1234567")
@account = Account.new(uid: @citizen.cpf,
password: "123mudar",
......
......@@ -3,7 +3,7 @@ require 'test_helper'
class Api::V1::ProfessionalsControllerTest < ActionDispatch::IntegrationTest
describe "Token access" do
before do
@parana = State.new(abbreviation: "PR",
@parana = State.new(abbreviation: "PR",
ibge_code: "41",
name: "Paraná")
@parana.save!
......@@ -13,14 +13,15 @@ class Api::V1::ProfessionalsControllerTest < ActionDispatch::IntegrationTest
state_id: @parana.id)
@curitiba.save!
@citizen= Citizen.new(cpf: "10845922904",
birth_date: "18/04/1997",
cep: "1234567",
email: "test@example.com",
name: "Test Example",
phone1: "(12)1212-1212",
rg: "1234567",
city_id: @curitiba.id)
@citizen= Citizen.new(active: true,
cpf: "10845922904",
birth_date: "18/04/1997",
cep: "1234567",
email: "test@example.com",
name: "Test Example",
phone1: "(12)1212-1212",
rg: "1234567",
city_id: @curitiba.id)
@account = Account.new(uid: @citizen.cpf,
password: "123mudar",
......
......@@ -15,14 +15,15 @@ class Api::V1::ServicePlacesControllerTest < ActionDispatch::IntegrationTest
state_id: @parana.id)
@curitiba.save!
@citizen= Citizen.new(cpf: "10845922904",
birth_date: "Apr 18 1997",
cep: "1234567",
email: "test@example.com",
name: "Test Example",
phone1: "(12)1212-1212",
city_id: @curitiba.id,
rg: "1234567")
@citizen= Citizen.new(active: true,
cpf: "10845922904",
birth_date: "Apr 18 1997",
cep: "1234567",
email: "test@example.com",
name: "Test Example",
phone1: "(12)1212-1212",
city_id: @curitiba.id,
rg: "1234567")
@account = Account.new(uid: @citizen.cpf,
password: "123mudar",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment