Compare commits

..
Author SHA1 Message Date
Weimin YuandGitHub 964f264c9d Add maven-publish task for SQL schema jar (#289)
* Add maven-publish task for SQL schema jar

Add task to publish SQL schema jar with flyway scripts and
golden schema to a maven repo. This will be used
for pre-release testing in the future.

This task is not part of build and needs to be invoked explicitly.

User needs to provide schema_jar_repo and schema_version
properties.

* Merge branch 'master' of https://github.com/google/nomulus into publish-schema-jar

* Add maven-publish task for SQL schema jar

Add task to publish SQL schema jar with flyway scripts and
golden schema to a maven repo. This will be used
for pre-release testing in the future.

This task is not part of build and needs to be invoked explicitly.

User needs to provide schema_jar_repo and schema_version
properties.
2019-10-02 14:27:36 -04:00
gbrodmanandGitHub cc018a6dac Don't crash on a null completion timestamp (#296)
* Don't crash on a null completion timestamp

* optional
2019-10-02 12:53:22 -04:00
Weimin YuandGitHub c25adbbd9c Restrict nomulus user access to flyway table (#297)
* Restrict nomulus user access to flyway table

The regular read-write user should not have write permissions to
the flyway metadata table.
2019-10-02 11:05:46 -04:00
gbrodmanandGitHub 42edf16f3f Edit a couple of nits in the db README (#291)
* Edit a couple of nits in the db README

* Update README.md
2019-09-30 15:50:19 -04:00
5 changed files with 46 additions and 8 deletions
@@ -21,7 +21,9 @@ import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
import google.registry.model.Buildable;
import google.registry.model.ImmutableObject;
import google.registry.util.DateTimeUtils;
import java.time.ZonedDateTime;
import java.util.Optional;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
@@ -149,8 +151,9 @@ public final class RegistryLock extends ImmutableObject implements Buildable {
return toJodaDateTime(creationTimestamp);
}
public DateTime getCompletionTimestamp() {
return toJodaDateTime(completionTimestamp);
/** Returns the completion timestamp, or empty if this lock has not been completed yet. */
public Optional<DateTime> getCompletionTimestamp() {
return Optional.ofNullable(completionTimestamp).map(DateTimeUtils::toJodaDateTime);
}
public String getVerificationCode() {
+3 -3
View File
@@ -18,12 +18,12 @@ Below are the steps to submit a schema change:
follow the V{id}__{description text}.sql, where {id} is a number that is
higher than all existing scripts in that folder. Also note that it is a
**double** underscore in the naming pattern.
* Run :db:tests from the Gradle root project. The SchemaTest will fail because
the new schema does not match the gold file.
* Run the `:db:test` task from the Gradle root project. The SchemaTest will
fail because the new schema does not match the golden file.
* Copy db/build/resources/test/testcontainer/mount/dump.txt to the golden file
(db/src/main/resources/sql/schema/nomulus.golden.sql). Diff it against the
old version and verify that all changes are expected.
* Retrun :db:tests. This time all tests should pass.
* Rerun the `:db:test` task. This time all tests should pass.
Relevant files (under db/src/main/resources/sql/schema/):
+30 -2
View File
@@ -12,10 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import com.google.common.collect.ImmutableList
plugins {
id "org.flywaydb.flyway" version "6.0.1"
id 'maven-publish'
}
ext {
@@ -75,6 +74,35 @@ ext {
}
}
task schemaJar(type: Jar) {
archiveBaseName = 'schema'
from(sourceSets.main.resources) {
include 'sql/flyway/**'
include 'sql/schema/nomulus.golden.sql'
}
}
artifacts {
archives schemaJar
}
publishing {
repositories {
maven {
url project.schema_jar_repo
}
}
publications {
schemaOrmPublication(MavenPublication) {
groupId 'google.registry'
artifactId 'schema'
version project.schema_version
artifact schemaJar
}
}
}
flyway {
def accessInfo = project.ext.getJdbcAccessInfo()
@@ -12,10 +12,12 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
-- Script to create a user with read-write permission to all tables.
-- Script to create a user with read-write permission to all tables (except for
-- WRITE permissions to flyway_schema_history).
CREATE USER :username ENCRYPTED PASSWORD :'password';
GRANT CONNECT ON DATABASE postgres TO :username;
GRANT USAGE ON SCHEMA public TO :username;
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO :username;
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO :username;
REVOKE INSERT, UPDATE, DELETE ON TABLE public.flyway_schema_history FROM :username;
+5
View File
@@ -15,3 +15,8 @@ dbServer=
dbName=postgres
dbUser=
dbPassword=
# Maven repository of the Cloud SQL schema jar, which contains the
# SQL DDL scripts.
schema_jar_repo=
schema_version=