Thanks to visit codestin.com
Credit goes to github.com

Skip to content

User database 24 - #25

Open
rmd6502 wants to merge 8 commits into
masterfrom
user_database_24
Open

User database 24#25
rmd6502 wants to merge 8 commits into
masterfrom
user_database_24

Conversation

@rmd6502

@rmd6502 rmd6502 commented Feb 13, 2017

Copy link
Copy Markdown
Contributor

Adds the 'team' and 'team_members' tables, and the ability to edit same for users. Using :through, establish a many:many relationship between users and teams.

@rmd6502

rmd6502 commented Feb 13, 2017

Copy link
Copy Markdown
Contributor Author

tests forthcoming, wanted to get this out to be sure it's what people had in mind

class CreateTeams < ActiveRecord::Migration[5.0]
def change
create_table :teams do |t|
t.string :team_name

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably just call this 'name' so rails magic works

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aha, actually, unless someone has an objection I think I'll keep this name - just discovered that in the users table 'name' is actually the slack name, not the user's name. I'll add first_name and last_name fields, and maybe rename 'name' to slack_name.
Or would it be better to rename users => slack_users and add a separate users table that can be 1:1 with slack_users (and other online services as we add them)?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, first_name, last_name and slack_name sounds good. no need for an extra table right now :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Let's rename columns on the users table like you described and let's also shorten this table's team_name to name.

create_table :team_members, :id => false do |t|
t.belongs_to :team
t.belongs_to :user
t.boolean :poc

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should add a default 'false'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default?

Comment thread db/schema.rb Outdated
create_table "team_members", force: :cascade do |t|
t.integer "team_id"
t.integer "user_id"
t.boolean "poc"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's poc?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

point of contact - if true, this user is a poc for this team

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it. I think, after the default, it's ready to be merged!

@rmd6502 rmd6502 self-assigned this Feb 18, 2017
@rmd6502

rmd6502 commented Feb 18, 2017

Copy link
Copy Markdown
Contributor Author

Hold off on merging this, still some issues, stand by

@rmd6502

rmd6502 commented Feb 18, 2017

Copy link
Copy Markdown
Contributor Author

Okay, was trying to be clever and remove the id from team_members, but since I'm working with the team_members relation as its own entity (i.e. the point_of_contact field), I'm pretty sure it needs the id field

@MiguelCarranza

MiguelCarranza commented Feb 21, 2017

Copy link
Copy Markdown
Contributor

Do you mean having user_id + team_id as Primary Key, and removing the ID? I mean, that's theoretically 3NF and right, but I've only seen it in practice a few times (I think it'd be particularly difficult to do with ActiveRecord / Rails). So don't worry about the automatic ID

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants