diff --git a/CHANGELOG.md b/CHANGELOG.md
index a927bf2..93ef533 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,12 @@ Until `1.0.0`, breaking changes may appear in any release and are flagged with *
default `databasechangelog` / `databasechangeloglock`. Override the new defaults
via configuration to keep the shared-table layout (see Added below).
([#37](https://github.com/softwaremill/okapi/issues/37))
+- **okapi's Liquibase migrations consolidated into a single
+ `001__create_okapi_outbox_table.sql` per database.** New installations create the
+ full schema (table + indexes) from one changeset instead of replaying the change
+ history; the resulting schema is unchanged. Existing installations from an earlier
+ release: the `outbox:001` changeset checksum changed — they must start on a fresh
+ okapi schema, or clear okapi's rows from `okapi_databasechangelog`, before upgrading.
### Added
diff --git a/okapi-mysql/src/main/resources/com/softwaremill/okapi/db/mysql/001__create_outbox_table.sql b/okapi-mysql/src/main/resources/com/softwaremill/okapi/db/mysql/001__create_okapi_outbox_table.sql
similarity index 78%
rename from okapi-mysql/src/main/resources/com/softwaremill/okapi/db/mysql/001__create_outbox_table.sql
rename to okapi-mysql/src/main/resources/com/softwaremill/okapi/db/mysql/001__create_okapi_outbox_table.sql
index b54bf2d..9b132e8 100644
--- a/okapi-mysql/src/main/resources/com/softwaremill/okapi/db/mysql/001__create_outbox_table.sql
+++ b/okapi-mysql/src/main/resources/com/softwaremill/okapi/db/mysql/001__create_okapi_outbox_table.sql
@@ -15,3 +15,7 @@ CREATE TABLE IF NOT EXISTS okapi_outbox
last_error TEXT,
delivery_metadata JSON NOT NULL
);
+
+CREATE INDEX idx_okapi_outbox_status_last_attempt ON okapi_outbox (status, last_attempt);
+
+CREATE INDEX idx_okapi_outbox_status_created_at ON okapi_outbox (status, created_at);
diff --git a/okapi-mysql/src/main/resources/com/softwaremill/okapi/db/mysql/002__add_purger_index.sql b/okapi-mysql/src/main/resources/com/softwaremill/okapi/db/mysql/002__add_purger_index.sql
deleted file mode 100644
index b53bf16..0000000
--- a/okapi-mysql/src/main/resources/com/softwaremill/okapi/db/mysql/002__add_purger_index.sql
+++ /dev/null
@@ -1,4 +0,0 @@
---liquibase formatted sql
---changeset outbox:002
-
-CREATE INDEX idx_okapi_outbox_status_last_attempt ON okapi_outbox(status, last_attempt);
diff --git a/okapi-mysql/src/main/resources/com/softwaremill/okapi/db/mysql/003__add_claim_index.sql b/okapi-mysql/src/main/resources/com/softwaremill/okapi/db/mysql/003__add_claim_index.sql
deleted file mode 100644
index 4cffaea..0000000
--- a/okapi-mysql/src/main/resources/com/softwaremill/okapi/db/mysql/003__add_claim_index.sql
+++ /dev/null
@@ -1,4 +0,0 @@
---liquibase formatted sql
---changeset outbox:003
-
-CREATE INDEX idx_okapi_outbox_status_created_at ON okapi_outbox (status, created_at);
diff --git a/okapi-mysql/src/main/resources/com/softwaremill/okapi/db/mysql/changelog.xml b/okapi-mysql/src/main/resources/com/softwaremill/okapi/db/mysql/changelog.xml
index 126d56b..390f883 100644
--- a/okapi-mysql/src/main/resources/com/softwaremill/okapi/db/mysql/changelog.xml
+++ b/okapi-mysql/src/main/resources/com/softwaremill/okapi/db/mysql/changelog.xml
@@ -3,7 +3,5 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
-
-
-
+
diff --git a/okapi-postgres/src/main/resources/com/softwaremill/okapi/db/postgres/001__create_outbox_table.sql b/okapi-postgres/src/main/resources/com/softwaremill/okapi/db/postgres/001__create_okapi_outbox_table.sql
similarity index 70%
rename from okapi-postgres/src/main/resources/com/softwaremill/okapi/db/postgres/001__create_outbox_table.sql
rename to okapi-postgres/src/main/resources/com/softwaremill/okapi/db/postgres/001__create_okapi_outbox_table.sql
index 466e065..58fc1bc 100644
--- a/okapi-postgres/src/main/resources/com/softwaremill/okapi/db/postgres/001__create_outbox_table.sql
+++ b/okapi-postgres/src/main/resources/com/softwaremill/okapi/db/postgres/001__create_okapi_outbox_table.sql
@@ -6,6 +6,7 @@ CREATE TABLE IF NOT EXISTS okapi_outbox
id UUID NOT NULL PRIMARY KEY,
message_type VARCHAR(255) NOT NULL,
payload TEXT NOT NULL,
+ delivery_type VARCHAR(50) NOT NULL,
status VARCHAR(50) NOT NULL DEFAULT 'PENDING',
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -14,3 +15,7 @@ CREATE TABLE IF NOT EXISTS okapi_outbox
last_error TEXT,
delivery_metadata JSONB NOT NULL
);
+
+CREATE INDEX IF NOT EXISTS idx_okapi_outbox_status_last_attempt ON okapi_outbox (status, last_attempt);
+
+CREATE INDEX IF NOT EXISTS idx_okapi_outbox_status_created_at ON okapi_outbox (status, created_at);
diff --git a/okapi-postgres/src/main/resources/com/softwaremill/okapi/db/postgres/002__add_delivery_type_column.sql b/okapi-postgres/src/main/resources/com/softwaremill/okapi/db/postgres/002__add_delivery_type_column.sql
deleted file mode 100644
index e75c2e1..0000000
--- a/okapi-postgres/src/main/resources/com/softwaremill/okapi/db/postgres/002__add_delivery_type_column.sql
+++ /dev/null
@@ -1,8 +0,0 @@
---liquibase formatted sql
---changeset outbox:002
-
-ALTER TABLE okapi_outbox ADD COLUMN IF NOT EXISTS delivery_type VARCHAR(50);
-
-UPDATE okapi_outbox SET delivery_type = delivery_metadata->>'type' WHERE delivery_type IS NULL;
-
-ALTER TABLE okapi_outbox ALTER COLUMN delivery_type SET NOT NULL;
diff --git a/okapi-postgres/src/main/resources/com/softwaremill/okapi/db/postgres/003__add_purger_index.sql b/okapi-postgres/src/main/resources/com/softwaremill/okapi/db/postgres/003__add_purger_index.sql
deleted file mode 100644
index 2fe114a..0000000
--- a/okapi-postgres/src/main/resources/com/softwaremill/okapi/db/postgres/003__add_purger_index.sql
+++ /dev/null
@@ -1,4 +0,0 @@
---liquibase formatted sql
---changeset outbox:003
-
-CREATE INDEX idx_okapi_outbox_status_last_attempt ON okapi_outbox(status, last_attempt);
diff --git a/okapi-postgres/src/main/resources/com/softwaremill/okapi/db/postgres/004__add_claim_index.sql b/okapi-postgres/src/main/resources/com/softwaremill/okapi/db/postgres/004__add_claim_index.sql
deleted file mode 100644
index 154e846..0000000
--- a/okapi-postgres/src/main/resources/com/softwaremill/okapi/db/postgres/004__add_claim_index.sql
+++ /dev/null
@@ -1,4 +0,0 @@
---liquibase formatted sql
---changeset outbox:004
-
-CREATE INDEX IF NOT EXISTS idx_okapi_outbox_status_created_at ON okapi_outbox (status, created_at);
diff --git a/okapi-postgres/src/main/resources/com/softwaremill/okapi/db/postgres/changelog.xml b/okapi-postgres/src/main/resources/com/softwaremill/okapi/db/postgres/changelog.xml
index 4ccc4e9..390f883 100644
--- a/okapi-postgres/src/main/resources/com/softwaremill/okapi/db/postgres/changelog.xml
+++ b/okapi-postgres/src/main/resources/com/softwaremill/okapi/db/postgres/changelog.xml
@@ -3,8 +3,5 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
-
-
-
-
+