[jOOQ/jOOQ#14476] Move experimental migrations API to DSLContext::migrations to avoid conflicts with transaction statements
This commit is contained in:
parent
3bbce6a7c8
commit
4e9589e71b
@ -265,54 +265,14 @@ public interface DSLContext extends Scope {
|
||||
DataSource diagnosticsDataSource();
|
||||
|
||||
/**
|
||||
* Initialise a {@link Version}.
|
||||
* The experimental migrations API.
|
||||
* <p>
|
||||
* This is EXPERIMENTAL functionality and subject to change in future jOOQ
|
||||
* versions.
|
||||
*/
|
||||
@Experimental
|
||||
@NotNull
|
||||
Version version(String id);
|
||||
|
||||
/**
|
||||
* Initialise a {@link Versions} graph.
|
||||
* <p>
|
||||
* This is EXPERIMENTAL functionality and subject to change in future jOOQ
|
||||
* versions.
|
||||
*/
|
||||
@Experimental
|
||||
@NotNull
|
||||
Versions versions();
|
||||
|
||||
/**
|
||||
* Initialise a {@link Version}.
|
||||
* <p>
|
||||
* This is EXPERIMENTAL functionality and subject to change in future jOOQ
|
||||
* versions.
|
||||
*/
|
||||
@Experimental
|
||||
@NotNull
|
||||
Commit commit(String id);
|
||||
|
||||
/**
|
||||
* Initialise a {@link Commits} graph.
|
||||
* <p>
|
||||
* This is EXPERIMENTAL functionality and subject to change in future jOOQ
|
||||
* versions.
|
||||
*/
|
||||
@Experimental
|
||||
@NotNull
|
||||
Commits commits();
|
||||
|
||||
/**
|
||||
* Create a migration from the currently installed version to a new version.
|
||||
* <p>
|
||||
* This is EXPERIMENTAL functionality and subject to change in future jOOQ
|
||||
* versions.
|
||||
*/
|
||||
@Experimental
|
||||
@NotNull
|
||||
Migration migrateTo(Commit to);
|
||||
Migrations migrations();
|
||||
|
||||
/**
|
||||
* Access the database meta data.
|
||||
|
||||
103
jOOQ/src/main/java/org/jooq/Migrations.java
Normal file
103
jOOQ/src/main/java/org/jooq/Migrations.java
Normal file
@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: https://www.jooq.org/legal/licensing
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.ApiStatus.Experimental;
|
||||
|
||||
/**
|
||||
* The experimental migrations API.
|
||||
* <p>
|
||||
* This is EXPERIMENTAL functionality and subject to change in future jOOQ
|
||||
* versions.
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
@Experimental
|
||||
public interface Migrations {
|
||||
|
||||
/**
|
||||
* Initialise a {@link Version}.
|
||||
* <p>
|
||||
* This is EXPERIMENTAL functionality and subject to change in future jOOQ
|
||||
* versions.
|
||||
*/
|
||||
@Experimental
|
||||
@NotNull
|
||||
Version version(String id);
|
||||
|
||||
/**
|
||||
* Initialise a {@link Versions} graph.
|
||||
* <p>
|
||||
* This is EXPERIMENTAL functionality and subject to change in future jOOQ
|
||||
* versions.
|
||||
*/
|
||||
@Experimental
|
||||
@NotNull
|
||||
Versions versions();
|
||||
|
||||
/**
|
||||
* Initialise a {@link Version}.
|
||||
* <p>
|
||||
* This is EXPERIMENTAL functionality and subject to change in future jOOQ
|
||||
* versions.
|
||||
*/
|
||||
@Experimental
|
||||
@NotNull
|
||||
Commit commit(String id);
|
||||
|
||||
/**
|
||||
* Initialise a {@link Commits} graph.
|
||||
* <p>
|
||||
* This is EXPERIMENTAL functionality and subject to change in future jOOQ
|
||||
* versions.
|
||||
*/
|
||||
@Experimental
|
||||
@NotNull
|
||||
Commits commits();
|
||||
|
||||
/**
|
||||
* Create a migration from the currently installed version to a new version.
|
||||
* <p>
|
||||
* This is EXPERIMENTAL functionality and subject to change in future jOOQ
|
||||
* versions.
|
||||
*/
|
||||
@Experimental
|
||||
@NotNull
|
||||
Migration migrateTo(Commit to);
|
||||
|
||||
}
|
||||
@ -335,7 +335,7 @@ final class CommitImpl extends AbstractNode<Commit> implements Commit {
|
||||
}
|
||||
|
||||
Map<String, File> versionFiles = new HashMap<>();
|
||||
Version from = version(ctx.version("init"), id(), versionFiles, history.values());
|
||||
Version from = version(ctx.migrations().version("init"), id(), versionFiles, history.values());
|
||||
Version to = version(from, resultCommit.id(), versionFiles, result.values());
|
||||
return new FilesImpl(from, to, result.values());
|
||||
}
|
||||
|
||||
@ -66,6 +66,6 @@ public class DefaultCommitProvider implements CommitProvider {
|
||||
|
||||
@Override
|
||||
public Commits provide() {
|
||||
return ctx.commits().load(migrations);
|
||||
return ctx.migrations().commits().load(migrations);
|
||||
}
|
||||
}
|
||||
|
||||
@ -397,28 +397,8 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version version(String id) {
|
||||
return new VersionImpl(this, id, null, new Version[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Versions versions() {
|
||||
return new VersionsImpl(version("init"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.Commit commit(String id) {
|
||||
return new CommitImpl(configuration, id, null, emptyList(), emptyList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Commits commits() {
|
||||
return new CommitsImpl(configuration, commit("init"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Migration migrateTo(org.jooq.Commit to) {
|
||||
return new MigrationImpl(configuration, to);
|
||||
public org.jooq.Migrations migrations() {
|
||||
return new MigrationsImpl(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
85
jOOQ/src/main/java/org/jooq/impl/MigrationsImpl.java
Normal file
85
jOOQ/src/main/java/org/jooq/impl/MigrationsImpl.java
Normal file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: https://www.jooq.org/legal/licensing
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static java.util.Collections.emptyList;
|
||||
|
||||
import org.jooq.Commit;
|
||||
import org.jooq.Commits;
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Migration;
|
||||
import org.jooq.Migrations;
|
||||
import org.jooq.Version;
|
||||
import org.jooq.Versions;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
final class MigrationsImpl implements Migrations {
|
||||
|
||||
final DSLContext ctx;
|
||||
|
||||
MigrationsImpl(DSLContext ctx) {
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Version version(String id) {
|
||||
return new VersionImpl(ctx, id, null, new Version[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Versions versions() {
|
||||
return new VersionsImpl(version("init"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Commit commit(String id) {
|
||||
return new CommitImpl(ctx.configuration(), id, null, emptyList(), emptyList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Commits commits() {
|
||||
return new CommitsImpl(ctx.configuration(), commit("init"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Migration migrateTo(Commit to) {
|
||||
return new MigrationImpl(ctx.configuration(), to);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user