flyway-sbt-test1

Slick classes generated from the database schema for the Transfer Digital Records service

License

License

MIT
Categories

Categories

Flyway Data Databases
GroupId

GroupId

uk.gov.nationalarchives
ArtifactId

ArtifactId

flyway-sbt-test1_2.13
Last Version

Last Version

0.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

flyway-sbt-test1
Slick classes generated from the database schema for the Transfer Digital Records service
Project URL

Project URL

https://github.com/nationalarchives/tdr-consignment-api-data
Project Organization

Project Organization

National Archives
Source Code Management

Source Code Management

https://github.com/nationalarchives/tdr-consignment-api-data

Download flyway-sbt-test1_2.13

How to add to project

<!-- https://jarcasting.com/artifacts/uk.gov.nationalarchives/flyway-sbt-test1_2.13/ -->
<dependency>
    <groupId>uk.gov.nationalarchives</groupId>
    <artifactId>flyway-sbt-test1_2.13</artifactId>
    <version>0.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/uk.gov.nationalarchives/flyway-sbt-test1_2.13/
implementation 'uk.gov.nationalarchives:flyway-sbt-test1_2.13:0.0.1'
// https://jarcasting.com/artifacts/uk.gov.nationalarchives/flyway-sbt-test1_2.13/
implementation ("uk.gov.nationalarchives:flyway-sbt-test1_2.13:0.0.1")
'uk.gov.nationalarchives:flyway-sbt-test1_2.13:jar:0.0.1'
<dependency org="uk.gov.nationalarchives" name="flyway-sbt-test1_2.13" rev="0.0.1">
  <artifact name="flyway-sbt-test1_2.13" type="jar" />
</dependency>
@Grapes(
@Grab(group='uk.gov.nationalarchives', module='flyway-sbt-test1_2.13', version='0.0.1')
)
libraryDependencies += "uk.gov.nationalarchives" % "flyway-sbt-test1_2.13" % "0.0.1"
[uk.gov.nationalarchives/flyway-sbt-test1_2.13 "0.0.1"]

Dependencies

compile (6)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.13.0
org.flywaydb : flyway-core jar 6.1.4
mysql : mysql-connector-java jar 5.1.16
com.typesafe.slick : slick_2.13 jar 3.3.2
com.typesafe.slick : slick-hikaricp_2.13 jar 3.3.2
com.typesafe.slick : slick-codegen_2.13 jar 3.3.2

Project Modules

There are no modules declared in this project.

Consignment API data

This project is part of Transfer Digital Records. It provides tools for working with the consignment database:

  • Database migrations
  • Scala code generation

Database Migrations

Adding a migration script

  • Add a sql file to lambda/src/main/resources/db/migration with a prefix of V\d__something.sql

The name of the migration should use snake_case, e.g. V123__add_date_column_to_series_table, because Flyway expects this format when it generates the migration name.

To run migrations locally, run sbt flywayMigrate.

Deployment

Run the following Jenkins jobs:

  • TDR Database Migrations Deploy: this builds the migration code and deploys it to the Lambda which will run the migrations
  • TDR Database Migrations Run: this runs the latest version of the migrations lambda

Migrations that have been merged to master will be run automatically on the Integration environment and can be run manually on other environments by the TDR Database Migrations Deploy Jenkins job. The job will:

  • Run a lambda which updates the database within that environment.
  • Use slick codegen to generate slick files based on the database schema.
  • Deploy this code to the S3 release bucket.

Code generation

The project uses slick-codegen to generate Slick classes based on the database structure

Publish generated code

  • Run the TDR Database Migrations Publish Jenkins job. This publishes a new version of the consignment-api-db library.

Using updated schema locally

To use updated schema locally for development, run the following commands:

sbt slickCodegen sbt publishLocal

This will place a snapshot version of the built project jar in the local .ivy cache folder: $HOME/.ivy2/local/uk.gov.nationalarchives/consignment-api-db_2.13/[version number]-SNAPSHOT

Other sbt projects that have this project as a dependency can access the local snapshot version by changing the version number in their build.sbt file, for example:

... other dependencies...
"uk.gov.nationalarchives" %% "consignment-api-db" % "[version number]-SNAPSHOT"
... other dependences...
uk.gov.nationalarchives

The National Archives, UK

Official archive of the UK government. Discover our online collections, research guides and educational resources spanning 1,000 years

Versions

Version
0.0.1