-
Notifications
You must be signed in to change notification settings - Fork 1
activerecords for team and team_user #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ced09a2
activerecords for team and team_user
uwjohnbee 5500a95
adding migration
uwjohnbee 761bf38
class ame fix
uwjohnbee edd0a5b
removing self
uwjohnbee 4581cdd
adding workspace id to teams table
uwjohnbee c798e26
removing index per PR feedback
uwjohnbee 8379e75
setting bigints, massaging FK adds
uwjohnbee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,13 @@ | ||
| class Team < ApplicationRecord | ||
| # == Schema Information | ||
| # | ||
| # Table name: teams | ||
| # | ||
| # id :bigint(8) not null, primary key | ||
| # name :string not null | ||
| # | ||
| # Indexes | ||
| # | ||
| # teams_name_idx (name) UNIQUE | ||
| # | ||
| end |
This file contains hidden or 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: team_user | ||
| # | ||
| # team_id :bigint(8) not null, primary key | ||
| # user_id :bigint(8) not null, primary key | ||
| # | ||
| # Indexes | ||
| # | ||
| # team_id_user_id_unique (team_id,user_id) UNIQUE | ||
| # | ||
| # Foreign Keys | ||
| # | ||
| # team_id_fkey (team_id => teams.id) | ||
| # user_id_fkey (user_id => users.id) | ||
| # | ||
| class TeamUser < ApplicationRecord | ||
| belongs_to :team | ||
| belongs_to :user | ||
| end |
This file contains hidden or 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,26 @@ | ||
| class CreateTeam < ActiveRecord::Migration[7.1] | ||
| def up | ||
| create_table :teams, primary_key: :id do |t| | ||
| t.integer :id | ||
| t.integer :workspace_id | ||
| t.string :name | ||
| end | ||
|
|
||
| add_index :teams, [:name, :workspace_id], unique: true | ||
| add_index :teams, :workspace_id | ||
|
|
||
| create_table :team_user do |t| | ||
| t.integer :team_id, null: false | ||
| t.integer :user_id, null: false | ||
| end | ||
|
|
||
| add_index :team_user, [:team_id, :user_id], unique: true | ||
| add_foreign_key :team_user, :teams, column: :team_id | ||
| add_foreign_key :team_user, :users, column: :user_id | ||
| end | ||
|
|
||
| def down | ||
| drop_table :team_user | ||
| drop_table :teams | ||
| end | ||
| end | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.