diff --git a/internal/services/link/infrastructure/store/crud/postgres/migrations/0000001_create_links_table.down.sql b/internal/services/link/infrastructure/store/crud/postgres/migrations/0000001_create_links_table.down.sql index 4779056b4b5..3c08050a470 100644 --- a/internal/services/link/infrastructure/store/crud/postgres/migrations/0000001_create_links_table.down.sql +++ b/internal/services/link/infrastructure/store/crud/postgres/migrations/0000001_create_links_table.down.sql @@ -1 +1 @@ -DROP TABLE IF EXISTS links; +DROP TABLE IF EXISTS shortlink.links; diff --git a/internal/services/link/infrastructure/store/crud/postgres/migrations/0000001_create_links_table.up.sql b/internal/services/link/infrastructure/store/crud/postgres/migrations/0000001_create_links_table.up.sql index 55858afe869..7440f7ce689 100644 --- a/internal/services/link/infrastructure/store/crud/postgres/migrations/0000001_create_links_table.up.sql +++ b/internal/services/link/infrastructure/store/crud/postgres/migrations/0000001_create_links_table.up.sql @@ -1,7 +1,13 @@ CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; +-- ShortLink Schema ==================================================================================================== + +CREATE SCHEMA IF NOT EXISTS shortlink; + +COMMENT ON SCHEMA shortlink IS 'Shortlink schema'; + -- Create a table for links -CREATE TABLE links +CREATE TABLE shortlink.links ( id UUID NOT NULL DEFAULT uuid_generate_v4(), CONSTRAINT id_links PRIMARY KEY(id), @@ -11,14 +17,14 @@ CREATE TABLE links json jsonb not null ) WITH (fillfactor = 100); -COMMENT ON TABLE links IS 'Link list'; +COMMENT ON TABLE shortlink.links IS 'Link list'; CREATE UNIQUE INDEX links_id_uindex - ON links (id); + ON shortlink.links (id); CREATE UNIQUE INDEX links_hash_uindex - ON links (hash); + ON shortlink.links (hash); -- INCLUDE-index -- as example: SELECT id, url, hash FROM links WHERE id = 10; -CREATE UNIQUE INDEX links_list ON links USING btree (hash) INCLUDE (url); +CREATE UNIQUE INDEX links_list ON shortlink.links USING btree (hash) INCLUDE (url); diff --git a/internal/services/link/infrastructure/store/crud/postgres/migrations/0000002_add_test_link.down.sql b/internal/services/link/infrastructure/store/crud/postgres/migrations/0000002_add_test_link.down.sql index e5248730393..5b233ba1f4e 100644 --- a/internal/services/link/infrastructure/store/crud/postgres/migrations/0000002_add_test_link.down.sql +++ b/internal/services/link/infrastructure/store/crud/postgres/migrations/0000002_add_test_link.down.sql @@ -1,7 +1,7 @@ BEGIN ISOLATION LEVEL READ COMMITTED; -DELETE FROM links +DELETE FROM shortlink.links WHERE hash IN ("myHash1", "myHash2", "myHash3") COMMIT; diff --git a/internal/services/link/infrastructure/store/crud/postgres/migrations/0000002_add_test_link.up.sql b/internal/services/link/infrastructure/store/crud/postgres/migrations/0000002_add_test_link.up.sql index b60b4880fc8..71890ecd202 100644 --- a/internal/services/link/infrastructure/store/crud/postgres/migrations/0000002_add_test_link.up.sql +++ b/internal/services/link/infrastructure/store/crud/postgres/migrations/0000002_add_test_link.up.sql @@ -4,13 +4,13 @@ BEGIN SAVEPOINT tx_create_default_links; -INSERT INTO links(url, hash, describe, json) +INSERT INTO shortlink.links(url, hash, describe, json) VALUES ('https://batazor.ru', 'myHash1', 'My personal website', '{"url":"https://batazor.ru", "hash":"myHash1","describe":"My personal website"}'); -INSERT INTO links(url, hash, describe, json) +INSERT INTO shortlink.links(url, hash, describe, json) VALUES ('https://github.com/batazor', 'myHash2', 'My accout of github', '{"url":"https://github.com/batazor", "hash":"myHash2","describe":"My accout of github"}'); -INSERT INTO links(url, hash, describe, json) +INSERT INTO shortlink.links(url, hash, describe, json) VALUES ('https://vk.com/batazor', 'myHash3', 'My page on vk.com', '{"url":"https://vk.com/batazor", "hash":"myHash3","describe":"My page on vk.com"}'); -- ROLLBACK TO tx_create_default_links; diff --git a/internal/services/link/infrastructure/store/crud/postgres/migrations/0000003_improve_links_table.down.sql b/internal/services/link/infrastructure/store/crud/postgres/migrations/0000003_improve_links_table.down.sql index 5c5fecda4a2..17405012c47 100644 --- a/internal/services/link/infrastructure/store/crud/postgres/migrations/0000003_improve_links_table.down.sql +++ b/internal/services/link/infrastructure/store/crud/postgres/migrations/0000003_improve_links_table.down.sql @@ -1,7 +1,7 @@ BEGIN ISOLATION LEVEL READ COMMITTED; -ALTER TABLE links DROP COLUMN created_at; -ALTER TABLE links DROP COLUMN updated_at; +ALTER TABLE shortlink.links DROP COLUMN created_at; +ALTER TABLE shortlink.links DROP COLUMN updated_at; COMMIT; diff --git a/internal/services/link/infrastructure/store/crud/postgres/migrations/0000003_improve_links_table.up.sql b/internal/services/link/infrastructure/store/crud/postgres/migrations/0000003_improve_links_table.up.sql index 57385193e68..537e17e0960 100644 --- a/internal/services/link/infrastructure/store/crud/postgres/migrations/0000003_improve_links_table.up.sql +++ b/internal/services/link/infrastructure/store/crud/postgres/migrations/0000003_improve_links_table.up.sql @@ -1,10 +1,10 @@ BEGIN ISOLATION LEVEL READ COMMITTED; -ALTER TABLE links +ALTER TABLE shortlink.links ADD created_at TIMESTAMP DEFAULT current_timestamp; -ALTER TABLE links +ALTER TABLE shortlink.links ADD updated_at TIMESTAMP DEFAULT current_timestamp; COMMIT; diff --git a/internal/services/link/infrastructure/store/crud/postgres/migrations/0000004_cqrs_link_view.up.sql b/internal/services/link/infrastructure/store/crud/postgres/migrations/0000004_cqrs_link_view.up.sql index 4ed54f570fd..411b723c0b1 100644 --- a/internal/services/link/infrastructure/store/crud/postgres/migrations/0000004_cqrs_link_view.up.sql +++ b/internal/services/link/infrastructure/store/crud/postgres/migrations/0000004_cqrs_link_view.up.sql @@ -1,9 +1,3 @@ --- ShortLink Schema ==================================================================================================== - -CREATE SCHEMA IF NOT EXISTS shortlink; - -COMMENT ON SCHEMA shortlink IS 'Shortlink schema'; - -- CQRS for links ====================================================================================================== CREATE TABLE shortlink.link_view ( diff --git a/internal/services/link/infrastructure/store/crud/postgres/migrations/0000005_move_link_to_schema_shortlink.up.sql b/internal/services/link/infrastructure/store/crud/postgres/migrations/0000005_move_link_to_schema_shortlink.up.sql deleted file mode 100644 index d3cd379ff70..00000000000 --- a/internal/services/link/infrastructure/store/crud/postgres/migrations/0000005_move_link_to_schema_shortlink.up.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE links - SET SCHEMA shortlink; diff --git a/internal/services/link/infrastructure/store/crud/postgres/migrations/000006_link_add_domain_link.down.sql b/internal/services/link/infrastructure/store/crud/postgres/migrations/000005_link_add_domain_link.down.sql similarity index 100% rename from internal/services/link/infrastructure/store/crud/postgres/migrations/000006_link_add_domain_link.down.sql rename to internal/services/link/infrastructure/store/crud/postgres/migrations/000005_link_add_domain_link.down.sql diff --git a/internal/services/link/infrastructure/store/crud/postgres/migrations/000006_link_add_domain_link.up.sql b/internal/services/link/infrastructure/store/crud/postgres/migrations/000005_link_add_domain_link.up.sql similarity index 100% rename from internal/services/link/infrastructure/store/crud/postgres/migrations/000006_link_add_domain_link.up.sql rename to internal/services/link/infrastructure/store/crud/postgres/migrations/000005_link_add_domain_link.up.sql diff --git a/internal/services/link/infrastructure/store/crud/postgres/migrations/0000005_move_link_to_schema_shortlink.down.sql b/internal/services/link/infrastructure/store/crud/postgres/migrations/000006_add_not_null_policy.down.sql similarity index 100% rename from internal/services/link/infrastructure/store/crud/postgres/migrations/0000005_move_link_to_schema_shortlink.down.sql rename to internal/services/link/infrastructure/store/crud/postgres/migrations/000006_add_not_null_policy.down.sql diff --git a/internal/services/link/infrastructure/store/crud/postgres/migrations/000007_add_not_null_policy.up.sql b/internal/services/link/infrastructure/store/crud/postgres/migrations/000006_add_not_null_policy.up.sql similarity index 100% rename from internal/services/link/infrastructure/store/crud/postgres/migrations/000007_add_not_null_policy.up.sql rename to internal/services/link/infrastructure/store/crud/postgres/migrations/000006_add_not_null_policy.up.sql diff --git a/internal/services/link/infrastructure/store/crud/postgres/migrations/000007_add_not_null_policy.down.sql b/internal/services/link/infrastructure/store/crud/postgres/migrations/000007_link_view_add_metadata_fields.down.sql similarity index 100% rename from internal/services/link/infrastructure/store/crud/postgres/migrations/000007_add_not_null_policy.down.sql rename to internal/services/link/infrastructure/store/crud/postgres/migrations/000007_link_view_add_metadata_fields.down.sql diff --git a/internal/services/link/infrastructure/store/crud/postgres/migrations/000008_link_view_add_metadata_fields.up.sql b/internal/services/link/infrastructure/store/crud/postgres/migrations/000007_link_view_add_metadata_fields.up.sql similarity index 100% rename from internal/services/link/infrastructure/store/crud/postgres/migrations/000008_link_view_add_metadata_fields.up.sql rename to internal/services/link/infrastructure/store/crud/postgres/migrations/000007_link_view_add_metadata_fields.up.sql diff --git a/internal/services/link/infrastructure/store/crud/postgres/migrations/000008_link_view_add_metadata_fields.down.sql b/internal/services/link/infrastructure/store/crud/postgres/migrations/000008_hot_cache.down.sql similarity index 100% rename from internal/services/link/infrastructure/store/crud/postgres/migrations/000008_link_view_add_metadata_fields.down.sql rename to internal/services/link/infrastructure/store/crud/postgres/migrations/000008_hot_cache.down.sql diff --git a/internal/services/link/infrastructure/store/crud/postgres/migrations/000008_hot_cache.up.sql b/internal/services/link/infrastructure/store/crud/postgres/migrations/000008_hot_cache.up.sql new file mode 100644 index 00000000000..f08f11ab2a6 --- /dev/null +++ b/internal/services/link/infrastructure/store/crud/postgres/migrations/000008_hot_cache.up.sql @@ -0,0 +1 @@ +CREATE EXTENSION IF NOT EXISTS pg_prewarm; diff --git a/internal/services/link/infrastructure/store/crud/postgres/migrations/000009_hot_cache.up.sql b/internal/services/link/infrastructure/store/crud/postgres/migrations/000009_hot_cache.up.sql deleted file mode 100644 index 867ed0ec169..00000000000 --- a/internal/services/link/infrastructure/store/crud/postgres/migrations/000009_hot_cache.up.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE EXTENSION pg_prewarm; diff --git a/internal/services/link/infrastructure/store/crud/postgres/migrations/000009_hot_cache.down.sql b/internal/services/link/infrastructure/store/crud/postgres/migrations/000009_hot_cache_enable.down.sql similarity index 100% rename from internal/services/link/infrastructure/store/crud/postgres/migrations/000009_hot_cache.down.sql rename to internal/services/link/infrastructure/store/crud/postgres/migrations/000009_hot_cache_enable.down.sql diff --git a/internal/services/link/infrastructure/store/crud/postgres/migrations/000010_hot_cache_enable.up.sql b/internal/services/link/infrastructure/store/crud/postgres/migrations/000009_hot_cache_enable.up.sql similarity index 100% rename from internal/services/link/infrastructure/store/crud/postgres/migrations/000010_hot_cache_enable.up.sql rename to internal/services/link/infrastructure/store/crud/postgres/migrations/000009_hot_cache_enable.up.sql diff --git a/internal/services/link/infrastructure/store/crud/postgres/migrations/000011_shortlink_optimization.down.sql b/internal/services/link/infrastructure/store/crud/postgres/migrations/000010_shortlink_optimization.down.sql similarity index 100% rename from internal/services/link/infrastructure/store/crud/postgres/migrations/000011_shortlink_optimization.down.sql rename to internal/services/link/infrastructure/store/crud/postgres/migrations/000010_shortlink_optimization.down.sql diff --git a/internal/services/link/infrastructure/store/crud/postgres/migrations/000011_shortlink_optimization.up.sql b/internal/services/link/infrastructure/store/crud/postgres/migrations/000010_shortlink_optimization.up.sql similarity index 100% rename from internal/services/link/infrastructure/store/crud/postgres/migrations/000011_shortlink_optimization.up.sql rename to internal/services/link/infrastructure/store/crud/postgres/migrations/000010_shortlink_optimization.up.sql diff --git a/internal/services/link/infrastructure/store/crud/postgres/migrations/000012_fts.down.sql b/internal/services/link/infrastructure/store/crud/postgres/migrations/000011_fts.down.sql similarity index 100% rename from internal/services/link/infrastructure/store/crud/postgres/migrations/000012_fts.down.sql rename to internal/services/link/infrastructure/store/crud/postgres/migrations/000011_fts.down.sql diff --git a/internal/services/link/infrastructure/store/crud/postgres/migrations/000012_fts.up.sql b/internal/services/link/infrastructure/store/crud/postgres/migrations/000011_fts.up.sql similarity index 100% rename from internal/services/link/infrastructure/store/crud/postgres/migrations/000012_fts.up.sql rename to internal/services/link/infrastructure/store/crud/postgres/migrations/000011_fts.up.sql diff --git a/internal/services/link/infrastructure/store/crud/postgres/migrations/000010_hot_cache_enable.down.sql b/internal/services/link/infrastructure/store/crud/postgres/migrations/000012_improve_migration.down.sql similarity index 100% rename from internal/services/link/infrastructure/store/crud/postgres/migrations/000010_hot_cache_enable.down.sql rename to internal/services/link/infrastructure/store/crud/postgres/migrations/000012_improve_migration.down.sql diff --git a/internal/services/link/infrastructure/store/crud/postgres/migrations/000013_improve_migration.up.sql b/internal/services/link/infrastructure/store/crud/postgres/migrations/000012_improve_migration.up.sql similarity index 100% rename from internal/services/link/infrastructure/store/crud/postgres/migrations/000013_improve_migration.up.sql rename to internal/services/link/infrastructure/store/crud/postgres/migrations/000012_improve_migration.up.sql diff --git a/internal/services/link/infrastructure/store/crud/postgres/migrations/000013_improve_migration.down.sql b/internal/services/link/infrastructure/store/crud/postgres/migrations/000013_improve_migration.down.sql deleted file mode 100644 index e69de29bb2d..00000000000