mirror of
https://github.com/gotson/komga.git
synced 2025-12-06 08:32:25 +01:00
added flyway for db migrations
This commit is contained in:
parent
fbb93b7266
commit
1c674916ce
12 changed files with 80 additions and 33 deletions
|
|
@ -1,26 +0,0 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="komga [bootRun] localdb,dev" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<ExternalSystemSettings>
|
||||
<option name="env">
|
||||
<map>
|
||||
<entry key="SPRING_PROFILES_ACTIVE" value="localdb,dev" />
|
||||
</map>
|
||||
</option>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value="" />
|
||||
<option name="taskDescriptions">
|
||||
<list />
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value="bootRun" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="vmOptions" value="" />
|
||||
</ExternalSystemSettings>
|
||||
<GradleScriptDebugEnabled>true</GradleScriptDebugEnabled>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
|
|
@ -38,6 +38,8 @@ dependencies {
|
|||
|
||||
kapt("org.springframework.boot:spring-boot-configuration-processor")
|
||||
|
||||
implementation("org.flywaydb:flyway-core:5.2.4")
|
||||
|
||||
// implementation("com.github.ben-manes.caffeine:caffeine:2.7.0")
|
||||
|
||||
implementation("io.github.microutils:kotlin-logging:1.6.26")
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class Book(
|
|||
) {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column(name = "id", nullable = false, unique = true)
|
||||
@Column(name = "id", nullable = false)
|
||||
@PrimaryKeyJoinColumn
|
||||
var id: Long = 0
|
||||
|
||||
|
|
|
|||
|
|
@ -39,8 +39,7 @@ class BookMetadata(
|
|||
lateinit var book: Book
|
||||
|
||||
@ElementCollection(fetch = FetchType.EAGER)
|
||||
@CollectionTable(name = "book_metadata_pages", joinColumns = [JoinColumn(name = "book_metadata_id")])
|
||||
@Column(name = "pages")
|
||||
@CollectionTable(name = "book_metadata_page", joinColumns = [JoinColumn(name = "book_metadata_id")])
|
||||
private val _pages: MutableList<BookPage> = mutableListOf()
|
||||
|
||||
val pages: List<BookPage>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
#logging.level.org.springframework.security.web.FilterChainProxy: DEBUG
|
||||
komga:
|
||||
root-folder: D:\\files
|
||||
# root-folder-scan-cron: 0 0 * * * ?
|
||||
# root-folder-scan-cron: 0 0 * * * ?
|
||||
spring:
|
||||
profiles:
|
||||
include: flyway
|
||||
|
|
|
|||
6
komga/src/main/resources/application-flyway.yml
Normal file
6
komga/src/main/resources/application-flyway.yml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
spring:
|
||||
flyway:
|
||||
enabled: true
|
||||
jpa:
|
||||
hibernate:
|
||||
ddl-auto: validate
|
||||
|
|
@ -2,6 +2,8 @@ spring:
|
|||
flyway:
|
||||
enabled: false
|
||||
jpa:
|
||||
hibernate:
|
||||
ddl-auto: none
|
||||
properties:
|
||||
javax:
|
||||
persistence:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
spring:
|
||||
datasource:
|
||||
url: jdbc:h2:./testdb;DB_CLOSE_DELAY=-1
|
||||
jpa:
|
||||
hibernate:
|
||||
ddl-auto: update
|
||||
|
||||
|
|
|
|||
6
komga/src/main/resources/application-noflyway.yml
Normal file
6
komga/src/main/resources/application-noflyway.yml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
spring:
|
||||
flyway:
|
||||
enabled: false
|
||||
jpa:
|
||||
hibernate:
|
||||
ddl-auto: create
|
||||
3
komga/src/main/resources/application-prod.yml
Normal file
3
komga/src/main/resources/application-prod.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
spring:
|
||||
profiles:
|
||||
include: flyway
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
create sequence hibernate_sequence start with 1 increment by 1;
|
||||
|
||||
create table book
|
||||
(
|
||||
id bigint generated by default as identity,
|
||||
name varchar not null,
|
||||
updated timestamp not null,
|
||||
url varchar not null,
|
||||
book_metadata_id bigint not null,
|
||||
serie_id bigint not null,
|
||||
primary key (id)
|
||||
);
|
||||
|
||||
create table book_metadata
|
||||
(
|
||||
id bigint generated by default as identity,
|
||||
media_type varchar,
|
||||
status varchar not null,
|
||||
thumbnail blob,
|
||||
primary key (id)
|
||||
);
|
||||
|
||||
create table book_metadata_page
|
||||
(
|
||||
book_metadata_id bigint not null,
|
||||
file_name varchar not null,
|
||||
media_type varchar not null
|
||||
);
|
||||
|
||||
create table serie
|
||||
(
|
||||
id bigint generated by default as identity,
|
||||
name varchar not null,
|
||||
updated timestamp not null,
|
||||
url varchar not null,
|
||||
primary key (id)
|
||||
);
|
||||
|
||||
alter table book
|
||||
add constraint uk_book_book_metadata_id unique (book_metadata_id);
|
||||
|
||||
alter table book
|
||||
add constraint fk_book_book_metadata_book_metadata_id foreign key (book_metadata_id) references book_metadata (id);
|
||||
|
||||
alter table book
|
||||
add constraint fk_book_serie_serie_id foreign key (serie_id) references serie (id);
|
||||
|
||||
alter table book_metadata_page
|
||||
add constraint fk_book_metadata_page_book_metadata_book_metadata_id foreign key (book_metadata_id) references book_metadata (id);
|
||||
|
|
@ -1,6 +1,11 @@
|
|||
application.version: TESTING
|
||||
|
||||
spring:
|
||||
flyway:
|
||||
enabled: true
|
||||
jpa:
|
||||
hibernate:
|
||||
ddl-auto: validate
|
||||
jpa:
|
||||
properties:
|
||||
hibernate:
|
||||
|
|
|
|||
Loading…
Reference in a new issue