-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
328 additions
and
151 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
40 changes: 40 additions & 0 deletions
40
...sources/org/broadinstitute/dsde/sam/liquibase/changesets/20230929_add_tos_audit_table.xml
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,40 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<databaseChangeLog logicalFilePath="dummy" | ||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd"> | ||
|
||
<changeSet logicalFilePath="dummy" author="tgarwood" id="add_tos_audit_table"> | ||
<createTable tableName="SAM_USER_TERMS_OF_SERVICE"> | ||
<column name="sam_user_id" type="VARCHAR"> | ||
<constraints primaryKey="true" foreignKeyName="FK_TOS_USER_ID" referencedTableName="SAM_USER" referencedColumnNames="id" deleteCascade="true"/> | ||
</column> | ||
<column name="version" type="VARCHAR(40)"> | ||
<constraints primaryKey="true"/> | ||
</column> | ||
<column name="action" type="VARCHAR"> | ||
<constraints primaryKey="true"/> | ||
</column> | ||
<column name="created_at" type="timestamptz"/> | ||
</createTable> | ||
|
||
<sql stripComments="true"> | ||
INSERT INTO sam_user_terms_of_service | ||
(sam_user_id, | ||
version, | ||
action, | ||
created_at) | ||
SELECT su.id as sam_user_id, | ||
su.accepted_tos_version as version, | ||
'ACCEPT' as action, | ||
'1970-01-01 00:00:00-00' as created_at | ||
FROM sam_user su | ||
WHERE su.accepted_tos_version is not null; | ||
</sql> | ||
|
||
<dropColumn tableName="sam_user"> | ||
<column name="accepted_tos_version"/> | ||
</dropColumn> | ||
</changeSet> | ||
</databaseChangeLog> |
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
39 changes: 39 additions & 0 deletions
39
src/main/scala/org/broadinstitute/dsde/workbench/sam/db/tables/TosTable.scala
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,39 @@ | ||
package org.broadinstitute.dsde.workbench.sam.db.tables | ||
|
||
import org.broadinstitute.dsde.workbench.model._ | ||
import org.broadinstitute.dsde.workbench.sam.db.SamTypeBinders | ||
import org.broadinstitute.dsde.workbench.sam.model.SamUserTos | ||
import scalikejdbc._ | ||
|
||
import java.time.Instant | ||
|
||
final case class TosRecord( | ||
samUserId: WorkbenchUserId, | ||
version: String, | ||
action: String, | ||
createdAt: Instant | ||
) | ||
|
||
object TosTable extends SQLSyntaxSupportWithDefaultSamDB[TosRecord] { | ||
val ACCEPT = "ACCEPT" | ||
val REJECT = "REJECT" | ||
override def tableName: String = "SAM_USER_TERMS_OF_SERVICE" | ||
|
||
import SamTypeBinders._ | ||
def apply(e: ResultName[TosRecord])(rs: WrappedResultSet): TosRecord = TosRecord( | ||
rs.get(e.samUserId), | ||
rs.get(e.version), | ||
rs.get(e.action), | ||
rs.get(e.createdAt) | ||
) | ||
|
||
def apply(o: SyntaxProvider[TosRecord])(rs: WrappedResultSet): TosRecord = apply(o.resultName)(rs) | ||
|
||
def unmarshalUserRecord(tosRecord: TosRecord): SamUserTos = | ||
SamUserTos( | ||
tosRecord.samUserId, | ||
tosRecord.version, | ||
tosRecord.action, | ||
tosRecord.createdAt | ||
) | ||
} |
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.