Migrations

This commit is contained in:
Eden Kirin
2023-09-14 22:12:28 +02:00
parent db8fba7207
commit d4a04adfda
8 changed files with 141 additions and 29 deletions

View File

@ -1,29 +0,0 @@
CREATE TABLE cities
(
id uuid DEFAULT gen_random_uuid() NOT NULL,
name varchar(50) NOT NULL,
postal_code varchar(10),
created_at timestamp WITH TIME ZONE DEFAULT NOW() NOT NULL,
updated_at timestamp WITH TIME ZONE DEFAULT NOW() NOT NULL,
sa_orm_sentinel uuid
);
CREATE UNIQUE INDEX cities_id_uindex
ON cities (id);
CREATE TABLE users
(
id uuid DEFAULT gen_random_uuid() NOT NULL,
first_name varchar(50),
last_name varchar(50),
city_id uuid
CONSTRAINT users_cities_id_fk
REFERENCES cities (),
created_at timestamp WITH TIME ZONE DEFAULT NOW() NOT NULL,
updated_at timestamp WITH TIME ZONE DEFAULT NOW() NOT NULL,
sa_orm_sentinel uuid
);
CREATE UNIQUE INDEX users_id_uindex
ON users (id);

View File

View File

@ -0,0 +1,12 @@
CREATE TABLE IF NOT EXISTS cities
(
id uuid DEFAULT gen_random_uuid() NOT NULL,
name varchar(50) NOT NULL,
postal_code varchar(10),
created_at timestamp WITH TIME ZONE DEFAULT NOW() NOT NULL,
updated_at timestamp WITH TIME ZONE DEFAULT NOW() NOT NULL,
sa_orm_sentinel uuid
);
CREATE UNIQUE INDEX IF NOT EXISTS cities_id_uindex
ON cities (id);

View File

@ -0,0 +1,15 @@
CREATE TABLE IF NOT EXISTS users
(
id uuid DEFAULT gen_random_uuid() NOT NULL,
first_name varchar(50),
last_name varchar(50),
city_id uuid
CONSTRAINT users_cities_id_fk
REFERENCES cities (id),
created_at timestamp WITH TIME ZONE DEFAULT NOW() NOT NULL,
updated_at timestamp WITH TIME ZONE DEFAULT NOW() NOT NULL,
sa_orm_sentinel uuid
);
CREATE UNIQUE INDEX IF NOT EXISTS users_id_uindex
ON users (id);

53
migrations/flyway.conf Normal file
View File

@ -0,0 +1,53 @@
flyway.connectRetries=0
# The SQL statements to run to initialize a new database connection immediately after opening it. (default: none)
flyway.initSql=set client_min_messages to warning;
flyway.locations=filesystem:migrations
# Comma-separated list of directories containing JDBC drivers and Java-based migrations.
# (default: <INSTALL-DIR>/jars)
# flyway.jarDirs=
flyway.sqlMigrationPrefix=V
flyway.repeatableSqlMigrationPrefix=R
flyway.sqlMigrationSeparator=__
flyway.sqlMigrationSuffixes=sql
flyway.placeholderReplacement=true
# Placeholders to replace in Sql migrations
# flyway.placeholders.user=
# flyway.placeholders.my_other_placeholder=
flyway.placeholderPrefix=${
flyway.placeholderSuffix=}
flyway.validateOnMigrate=false
flyway.cleanOnValidationError=false
flyway.cleanDisabled=true
flyway.baselineVersion=0000
flyway.baselineOnMigrate=false
flyway.outOfOrder=true
flyway.validateMigrationNaming=true
# This allows you to tie in custom code and logic to the Flyway lifecycle notifications (default: empty).
# Set this to a comma-separated list of fully qualified class names of org.flywaydb.core.api.callback.Callback
# implementations.
# flyway.callbacks=
# If set to true, default built-in callbacks (sql) are skipped and only custom callback as
# defined by 'flyway.callbacks' are used. (default: false)
# flyway.skipDefaultCallbacks=
flyway.ignoreMissingMigrations=false
flyway.ignoreIgnoredMigrations=false
flyway.ignorePendingMigrations=false
flyway.ignoreFutureMigrations=true
flyway.mixed=false
flyway.group=false
flyway.installedBy=