-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrations for basic data models (user, school, provider)
- Loading branch information
Showing
32 changed files
with
561 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# == Schema Information | ||
# | ||
# Table name: schools | ||
# | ||
# id :uuid not null, primary key | ||
# claims :boolean default(FALSE) | ||
# placements :boolean default(FALSE) | ||
# urn :string not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
# Indexes | ||
# | ||
# index_schools_on_claims (claims) | ||
# index_schools_on_placements (placements) | ||
# index_schools_on_urn (urn) UNIQUE | ||
# | ||
class Claims::School < School | ||
default_scope { claims } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# == Schema Information | ||
# | ||
# Table name: users | ||
# | ||
# id :uuid not null, primary key | ||
# email :string not null | ||
# first_name :string not null | ||
# last_name :string not null | ||
# service :enum not null | ||
# support_user :boolean default(FALSE) | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
# Indexes | ||
# | ||
# index_users_on_service_and_email (service,email) UNIQUE | ||
# | ||
class Claims::User < User | ||
default_scope { claims } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# == Schema Information | ||
# | ||
# Table name: schools | ||
# | ||
# id :uuid not null, primary key | ||
# claims :boolean default(FALSE) | ||
# placements :boolean default(FALSE) | ||
# urn :string not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
# Indexes | ||
# | ||
# index_schools_on_claims (claims) | ||
# index_schools_on_placements (placements) | ||
# index_schools_on_urn (urn) UNIQUE | ||
# | ||
class Placements::School < School | ||
default_scope { placements } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# == Schema Information | ||
# | ||
# Table name: users | ||
# | ||
# id :uuid not null, primary key | ||
# email :string not null | ||
# first_name :string not null | ||
# last_name :string not null | ||
# service :enum not null | ||
# support_user :boolean default(FALSE) | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
# Indexes | ||
# | ||
# index_users_on_service_and_email (service,email) UNIQUE | ||
# | ||
class Placements::SupportUser < Placements::User | ||
default_scope { support_users } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# == Schema Information | ||
# | ||
# Table name: users | ||
# | ||
# id :uuid not null, primary key | ||
# email :string not null | ||
# first_name :string not null | ||
# last_name :string not null | ||
# service :enum not null | ||
# support_user :boolean default(FALSE) | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
# Indexes | ||
# | ||
# index_users_on_service_and_email (service,email) UNIQUE | ||
# | ||
class Placements::User < User | ||
default_scope { placements } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# == Schema Information | ||
# | ||
# Table name: providers | ||
# | ||
# id :uuid not null, primary key | ||
# provider_code :string not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
# Indexes | ||
# | ||
# index_providers_on_provider_code (provider_code) UNIQUE | ||
# | ||
class Provider < ApplicationRecord | ||
validates :provider_code, presence: true | ||
validates :provider_code, uniqueness: { case_sensitive: false } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# == Schema Information | ||
# | ||
# Table name: schools | ||
# | ||
# id :uuid not null, primary key | ||
# claims :boolean default(FALSE) | ||
# placements :boolean default(FALSE) | ||
# urn :string not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
# Indexes | ||
# | ||
# index_schools_on_claims (claims) | ||
# index_schools_on_placements (placements) | ||
# index_schools_on_urn (urn) UNIQUE | ||
# | ||
class School < ApplicationRecord | ||
has_one :gias_school, foreign_key: :urn, primary_key: :urn | ||
validates :urn, presence: true | ||
validates :urn, uniqueness: { case_sensitive: false } | ||
|
||
scope :placements, -> { where placements: true } | ||
scope :claims, -> { where claims: true } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class CreateSchools < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :schools, id: :uuid do |t| | ||
t.string :urn, null: false, index: { unique: true } | ||
t.boolean :placements, default: false, index: true | ||
t.boolean :claims, default: false, index: true | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class CreateProviders < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :providers, id: :uuid do |t| | ||
t.string :provider_code, null: false, index: { unique: true } | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddSupportUserToUsers < ActiveRecord::Migration[7.1] | ||
def change | ||
add_column :users, :support_user, :boolean, default: false | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class AddServiceEnumToUser < ActiveRecord::Migration[7.1] | ||
def change | ||
create_enum :service, %w[claims placements] | ||
add_column :users, :service, :enum, enum_type: "service", null: false # rubocop:disable Rails/NotNullColumn | ||
end | ||
end |
6 changes: 6 additions & 0 deletions
6
db/migrate/20231216102842_add_index_to_users_on_email_and_service.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class AddIndexToUsersOnEmailAndService < ActiveRecord::Migration[7.1] | ||
def change | ||
remove_index :users, :email | ||
add_index :users, %i[service email], unique: true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.