Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 20 additions & 27 deletions augur/application/db/models/augur_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,18 @@ class Contributor(Base):
__tablename__ = "contributors"
__table_args__ = (
# add uniques explitcitly, they were inline before
UniqueConstraint('gh_login', name='GH-UNIQUE-C', initially="DEFERRED", deferrable=True),
UniqueConstraint('gl_id', name='GL-UNIQUE-B', initially="DEFERRED", deferrable=True),

# unique key for gitlab users on insertion
UniqueConstraint('gl_username', name='GL-UNIQUE-C', initially="DEFERRED", deferrable=True),
UniqueConstraint('cntrb_login', name='GL-cntrb-LOGIN-UNIQUE'),


# changed from inline to not inline
Index("cnt-fullname", "cntrb_full_name", postgresql_using='hash'),
Index("cntrb-theemail", "cntrb_email", postgresql_using='hash'),
Index("contributors_idx_cntrb_email3", "cntrb_email"),
Index("cntrb_canonica-idx11", "cntrb_canonical"),
Index("cntrb_login_platform_index", "cntrb_login"),
Index("gh_login", text("gh_login ASC NULLS FIRST")),


# added
Expand Down Expand Up @@ -813,6 +811,7 @@ class Repo(Base):
__tablename__ = "repo"
__table_args__ = (
UniqueConstraint("repo_git", name="repo_git-unique"),
UniqueConstraint("repo_src_id", name="repo_src_id_unique"),

Index("forked", "forked_from"),
Index("repo_idx_repo_id_repo_namex", "repo_id", "repo_name"),
Expand Down Expand Up @@ -1319,29 +1318,19 @@ class Commit(Base):
cmt_whitespace = Column(Integer, nullable=False)
cmt_filename = Column(String, nullable=False)
cmt_date_attempted = Column(TIMESTAMP(precision=0), nullable=False)
cmt_ght_author_id = Column(ForeignKey("augur_data.contributors.cntrb_id"))
cmt_ght_author_id = Column(ForeignKey(
"augur_data.contributors.cntrb_id",
name="cmt_ght_author_cntrb_id_fk",
onupdate="CASCADE",
ondelete="RESTRICT",
initially="DEFERRED",
deferrable=True
))
cmt_ght_committer_id = Column(Integer)
cmt_ght_committed_at = Column(TIMESTAMP(precision=0))
cmt_committer_timestamp = Column(TIMESTAMP(True, 0))
cmt_author_timestamp = Column(TIMESTAMP(True, 0))
cmt_author_platform_username = Column(
ForeignKey(
"augur_data.contributors.cntrb_login",
name="fk_commits_contributors_3",
ondelete="CASCADE",
onupdate="CASCADE",
initially="DEFERRED",
deferrable=True,
),
ForeignKey(
"augur_data.contributors.cntrb_login",
name="fk_commits_contributors_4",
ondelete="CASCADE",
onupdate="CASCADE",
initially="DEFERRED",
deferrable=True,
),
)
cmt_author_platform_username = Column(String)
tool_source = Column(String)
tool_version = Column(String)
data_source = Column(String)
Expand Down Expand Up @@ -1695,10 +1684,11 @@ class PullRequest(Base):
UniqueConstraint("repo_id", "pr_src_id", name="unique-pr"),
UniqueConstraint("repo_id", "pr_src_id", name="unique-prx"),
UniqueConstraint("pr_url", name="pull-request-insert-unique"),
Index("id_node", "pr_src_id", "pr_src_node_id"),
Index("id_node", text("pr_src_id DESC"), text("pr_src_node_id DESC NULLS LAST")),
Index(
"pull_requests_idx_repo_id_data_datex", "repo_id", "data_collection_date"
),
Index("pr_ID_prs_table", "pull_request_id"),
{"schema": "augur_data"},
)

Expand Down Expand Up @@ -1835,7 +1825,7 @@ class Release(Base):
__table_args__ = {"schema": "augur_data"}

release_id = Column(
CHAR(128),
CHAR(256),
primary_key=True,
server_default=text("nextval('augur_data.releases_release_id_seq'::regclass)"),
)
Expand Down Expand Up @@ -1999,7 +1989,7 @@ class RepoDepsLibyear(Base):
class RepoDepsScorecard(Base):
__tablename__ = "repo_deps_scorecard"
__table_args__ = (
UniqueConstraint("repo_id","name", name="deps-scorecard-insert-unique"),
UniqueConstraint("repo_id","name", "data_collection_date", name="deps_scorecard_new_unique"),
{"schema": "augur_data"}
)

Expand Down Expand Up @@ -2962,6 +2952,7 @@ class PullRequestEvent(Base):
__table_args__ = (
Index("pr_events_ibfk_1", "pull_request_id"),
Index("pr_events_ibfk_2", "cntrb_id"),
UniqueConstraint("repo_id", "issue_event_src_id", name="pr_events_repo_id_event_src_id_unique"),
UniqueConstraint("platform_id", "node_id", name="unique-pr-event-id"),
UniqueConstraint("node_id", name="pr-unqiue-event"),
{"schema": "augur_data"},
Expand Down Expand Up @@ -3058,7 +3049,8 @@ def from_github(cls, event, pr_id, repo_id, tool_source, tool_version, data_sour
class PullRequestFile(Base):
__tablename__ = "pull_request_files"
__table_args__ = (
UniqueConstraint("pull_request_id", "repo_id", "pr_file_path"),
Index("pr_id_pr_files","pull_request_id"),
UniqueConstraint("pull_request_id", "repo_id", "pr_file_path", name="prfiles_unique"),
{
"schema": "augur_data",
"comment": "Pull request commits are an enumeration of each commit associated with a pull request. \nNot all pull requests are from a branch or fork into master. \nThe commits table intends to count only commits that end up in the master branch (i.e., part of the deployed code base for a project).\nTherefore, there will be commit “SHA”’s in this table that are no associated with a commit SHA in the commits table. \nIn cases where the PR is to the master branch of a project, you will find a match. In cases where the PR does not involve the master branch, you will not find a corresponding commit SHA in the commits table. This is expected. ",
Expand Down Expand Up @@ -3357,7 +3349,8 @@ def from_github(cls, reviewer, repo_id, tool_source, tool_version, data_source):
class PullRequestReview(Base):
__tablename__ = "pull_request_reviews"
__table_args__ = (
UniqueConstraint("pr_review_src_id", "tool_source"),
UniqueConstraint("pr_review_src_id", name="pr_review_unique"),
Index("pr_id_pr_reviews", "pull_request_id"),
{"schema": "augur_data"},
)

Expand Down
10 changes: 5 additions & 5 deletions augur/application/db/models/augur_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class User(Base):
tool_version = Column(String)
data_source = Column(String)
data_collection_date = Column(TIMESTAMP(precision=0), server_default=text("CURRENT_TIMESTAMP"))

email_verified = Column(Boolean, server_default='false', nullable=False)

groups = relationship("UserGroup", back_populates="user")
tokens = relationship("UserSessionToken", back_populates="user")
Expand Down Expand Up @@ -630,13 +630,13 @@ def compute_hashsed_password(password):
class UserGroup(Base):
__tablename__ = 'user_groups'
__table_args__ = (
UniqueConstraint('user_id', 'name', name='user_group_unique'),
UniqueConstraint('user_id', 'name', name='user_groups_user_id_name_key'),
{"schema": "augur_operations"}
)

group_id = Column(BigInteger, primary_key=True)
user_id = Column(Integer,
ForeignKey("augur_operations.users.user_id", name="user_group_user_id_fkey")
ForeignKey("augur_operations.users.user_id", name="user_group_user_id_fkey"), nullable=False
)
name = Column(String, nullable=False)
favorited = Column(Boolean, nullable=False, server_default=text("FALSE"))
Expand Down Expand Up @@ -1010,9 +1010,9 @@ class UserSessionToken(Base):
__table_args__ = { "schema": "augur_operations" }

token = Column(String, primary_key=True, nullable=False)
user_id = Column(ForeignKey("augur_operations.users.user_id", name="user_session_token_user_id_fkey"))
user_id = Column(ForeignKey("augur_operations.users.user_id", name="user_session_token_user_id_fkey"), nullable=False)
expiration = Column(BigInteger)
application_id = Column(ForeignKey("augur_operations.client_applications.id", name="user_session_token_application_id_fkey"), nullable=False)
application_id = Column(ForeignKey("augur_operations.client_applications.id", name="user_session_token_application_id_fkey"))
created_at = Column(BigInteger)

user = relationship("User", back_populates="tokens")
Expand Down
Loading