{"id":20905217,"url":"https://github.com/akkadotnet/akka.persistence.postgresql","last_synced_at":"2025-04-07T09:24:12.778Z","repository":{"id":32422717,"uuid":"36000087","full_name":"akkadotnet/Akka.Persistence.PostgreSql","owner":"akkadotnet","description":"Akka.Persistence.PostgreSql provider","archived":false,"fork":false,"pushed_at":"2024-05-15T18:40:28.000Z","size":2440,"stargazers_count":32,"open_issues_count":17,"forks_count":35,"subscribers_count":11,"default_branch":"dev","last_synced_at":"2024-05-16T14:54:01.642Z","etag":null,"topics":["akka","akkadotnet","postgresql"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akkadotnet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-05-21T08:15:14.000Z","updated_at":"2024-06-21T14:14:43.975Z","dependencies_parsed_at":"2024-06-21T14:14:41.668Z","dependency_job_id":"033711dd-f081-473a-8f0a-5613917a7537","html_url":"https://github.com/akkadotnet/Akka.Persistence.PostgreSql","commit_stats":{"total_commits":131,"total_committers":23,"mean_commits":5.695652173913044,"dds":0.7251908396946565,"last_synced_commit":"c57876d4f1dbfbb0f1746ff3f460081c452bd448"},"previous_names":["akkanetcontrib/akka.persistence.postgresql"],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akkadotnet%2FAkka.Persistence.PostgreSql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akkadotnet%2FAkka.Persistence.PostgreSql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akkadotnet%2FAkka.Persistence.PostgreSql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akkadotnet%2FAkka.Persistence.PostgreSql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akkadotnet","download_url":"https://codeload.github.com/akkadotnet/Akka.Persistence.PostgreSql/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247623726,"owners_count":20968741,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["akka","akkadotnet","postgresql"],"created_at":"2024-11-18T13:23:25.127Z","updated_at":"2025-04-07T09:24:12.751Z","avatar_url":"https://github.com/akkadotnet.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deprecation Notice: Akka.Persistence.PostgreSql\n\n\u003e [!WARNING]\n\u003e\n\u003e All Akka.Persistence plugins based on the `Akka.Persistence.Sql.Common` package are now **deprecated**. We strongly recommend that you migrate to the new [`Akka.Persistence.Sql` or the `Akka.Persistence.Sql.Hosting`](https://github.com/akkadotnet/Akka.Persistence.Sql) package.\n\n## Migration Resources\n\nTo assist with the migration, please refer to the following resources:\n\n- **Migration Guide:**  \n  Learn the necessary steps to upgrade by following the [Migration Guide](https://github.com/akkadotnet/Akka.Persistence.Sql/blob/dev/docs/articles/migration.md).\n\n- **Migration Walkthrough:**  \n  For a step-by-step walkthrough, check out our [Migration Walkthrough](https://github.com/akkadotnet/Akka.Persistence.Sql/blob/dev/docs/articles/migration-walkthrough.md).\n\n- **Migration Guide Video:**  \n  Watch the [Migration Guide Video](https://www.youtube.com/watch?v=gSmqUrVHPq8) on YouTube for a detailed explanation of the migration process.\n\n---\n\n# Akka.Persistence.PostgreSql\n\nAkka Persistence journal and snapshot store backed by PostgreSql database.\n\n### Configuration\n\nBoth journal and snapshot store share the same configuration keys (however they resides in separate scopes, so they are definied distinctly for either journal or snapshot store):\n\nRemember that connection string must be provided separately to Journal and Snapshot Store.\n\n```hocon\nakka.persistence{\n\tjournal {\n\t\tplugin = \"akka.persistence.journal.postgresql\"\n\t\tpostgresql {\n\t\t\t# qualified type name of the PostgreSql persistence journal actor\n\t\t\tclass = \"Akka.Persistence.PostgreSql.Journal.PostgreSqlJournal, Akka.Persistence.PostgreSql\"\n\n\t\t\t# dispatcher used to drive journal actor\n\t\t\tplugin-dispatcher = \"akka.actor.default-dispatcher\"\n\n\t\t\t# connection string used for database access\n\t\t\tconnection-string = \"\"\n\n\t\t\t# default SQL commands timeout\n\t\t\tconnection-timeout = 30s\n\n\t\t\t# PostgreSql schema name to table corresponding with persistent journal\n\t\t\tschema-name = public\n\n\t\t\t# PostgreSql table corresponding with persistent journal\n\t\t\ttable-name = event_journal\n\n\t\t\t# should corresponding journal table be initialized automatically\n\t\t\tauto-initialize = off\n\t\t\t\n\t\t\t# timestamp provider used for generation of journal entries timestamps\n\t\t\ttimestamp-provider = \"Akka.Persistence.Sql.Common.Journal.DefaultTimestampProvider, Akka.Persistence.Sql.Common\"\n\t\t\n\t\t\t# metadata table\n\t\t\tmetadata-table-name = metadata\n\n\t\t\t# defines column db type used to store payload. Available option: BYTEA (default), JSON, JSONB\n\t\t\tstored-as = BYTEA\n\n\t\t\t# Setting used to toggle sequential read access when loading large objects\n\t\t\t# from journals and snapshot stores.\n\t\t\tsequential-access = off\n\n\t\t\t# When turned on, persistence will use `BIGINT` and `GENERATED ALWAYS AS IDENTITY`\n\t\t\t# for journal table schema creation.\n\t\t\t# NOTE: This only affects newly created tables, as such, it should not affect any\n\t\t\t#       existing database.\n\t\t\t#\n\t\t\t# !!!!! WARNING !!!!!\n\t\t\t# To use this feature, you have to have PorsgreSql version 10 or above\n\t\t\tuse-bigint-identity-for-ordering-column = off\n\n\t\t\t# Setting used to change size of the tags column in persistent journal table\n\t\t\ttags-column-size = 2000\n\t\t}\n\t}\n\n\tsnapshot-store {\n\t\tplugin = \"akka.persistence.snapshot-store.postgresql\"\n\t\tpostgresql {\n\t\t\t# qualified type name of the PostgreSql persistence journal actor\n\t\t\tclass = \"Akka.Persistence.PostgreSql.Snapshot.PostgreSqlSnapshotStore, Akka.Persistence.PostgreSql\"\n\n\t\t\t# dispatcher used to drive journal actor\n\t\t\tplugin-dispatcher = \"\"akka.actor.default-dispatcher\"\"\n\n\t\t\t# connection string used for database access\n\t\t\tconnection-string = \"\"\n\n\t\t\t# default SQL commands timeout\n\t\t\tconnection-timeout = 30s\n\n\t\t\t# PostgreSql schema name to table corresponding with persistent journal\n\t\t\tschema-name = public\n\n\t\t\t# PostgreSql table corresponding with persistent journal\n\t\t\ttable-name = snapshot_store\n\n\t\t\t# should corresponding journal table be initialized automatically\n\t\t\tauto-initialize = off\n\t\t\t\n\t\t\t# defines column db type used to store payload. Available option: BYTEA (default), JSON, JSONB\n\t\t\tstored-as = BYTEA\n\n\t\t\t# Setting used to toggle sequential read access when loading large objects\n\t\t\t# from journals and snapshot stores.\n\t\t\tsequential-access = off\n\t\t}\n\t}\n}\n```\n### Table Schema\n\nPostgreSql persistence plugin defines a default table schema used for journal, snapshot store and metadate table.\n\n```SQL\nCREATE TABLE {your_journal_table_name} (\n\tordering BIGSERIAL NOT NULL PRIMARY KEY,\n    persistence_id VARCHAR(255) NOT NULL,\n    sequence_nr BIGINT NOT NULL,\n    is_deleted BOOLEAN NOT NULL,\n    created_at BIGINT NOT NULL,\n    manifest VARCHAR(500) NOT NULL,\n    payload BYTEA NOT NULL,\n    tags VARCHAR(100) NULL,\n    serializer_id INTEGER NULL,\n    CONSTRAINT {your_journal_table_name}_uq UNIQUE (persistence_id, sequence_nr)\n);\n\nCREATE TABLE {your_snapshot_table_name} (\n    persistence_id VARCHAR(255) NOT NULL,\n    sequence_nr BIGINT NOT NULL,\n    created_at BIGINT NOT NULL,\n    manifest VARCHAR(500) NOT NULL,\n    payload BYTEA NOT NULL,\n    serializer_id INTEGER NULL,\n    CONSTRAINT {your_snapshot_table_name}_pk PRIMARY KEY (persistence_id, sequence_nr)\n);\n\nCREATE TABLE {your_metadata_table_name} (\n    persistence_id VARCHAR(255) NOT NULL,\n    sequence_nr BIGINT NOT NULL,\n    CONSTRAINT {your_metadata_table_name}_pk PRIMARY KEY (persistence_id, sequence_nr)\n);\n```\n\nNote that if you turn on the `akka.persistence.journal.postgresql.use-bigint-identity-for-ordering-column` flag, the journal table schema will be altered to the latest recommended primary key setting.\n```\nCREATE TABLE {your_journal_table_name} (\n\tordering BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY PRIMARY KEY,\n    persistence_id VARCHAR(255) NOT NULL,\n    sequence_nr BIGINT NOT NULL,\n    is_deleted BOOLEAN NOT NULL,\n    created_at BIGINT NOT NULL,\n    manifest VARCHAR(500) NOT NULL,\n    payload BYTEA NOT NULL,\n    tags VARCHAR(100) NULL,\n    serializer_id INTEGER NULL,\n    CONSTRAINT {your_journal_table_name}_uq UNIQUE (persistence_id, sequence_nr)\n);\n```\nSince this script is only run once during table generation, we will not provide any migration path for this change, any migration is left as an exercise for the user.\n\n### Migration\n\n#### From 1.1.0 to 1.3.1\n```SQL\nALTER TABLE {your_journal_table_name} ADD COLUMN serializer_id INTEGER NULL;\nALTER TABLE {your_snapshot_table_name} ADD COLUMN serializer_id INTEGER NULL;\n```\n\n#### From 1.0.6 to 1.1.0\n```SQL\nCREATE TABLE {your_metadata_table_name} (\n    persistence_id VARCHAR(255) NOT NULL,\n    sequence_nr BIGINT NOT NULL,\n    CONSTRAINT {your_metadata_table_name}_pk PRIMARY KEY (persistence_id, sequence_nr)\n);\n\nALTER TABLE {your_journal_table_name} DROP CONSTRAINT {your_journal_table_name}_pk;\nALTER TABLE {your_journal_table_name} ADD COLUMN ordering BIGSERIAL NOT NULL PRIMARY KEY;\nALTER TABLE {your_journal_table_name} ADD COLUMN tags VARCHAR(100) NULL;\nALTER TABLE {your_journal_table_name} ADD CONSTRAINT {your_journal_table_name}_uq UNIQUE (persistence_id, sequence_nr);\nALTER TABLE {your_journal_table_name} ADD COLUMN created_at_temp BIGINT NOT NULL;\n\nUPDATE {your_journal_table_name} SET created_at_temp=extract(epoch from create_at);\n\nALTER TABLE {your_journal_table_name} DROP COLUMN create_at;\nALTER TABLE {your_journal_table_name} DROP COLUMN created_at_ticks;\nALTER TABLE {your_journal_table_name} RENAME COLUMN created_at_temp TO create_at;\n```\n\n### Tests\n\nThe PostgreSql tests are packaged and run as part of the default \"All\" build task.\n\nIn order to run the tests, you must do the following things:\n\n1. Download and install PostgreSql from: http://www.postgresql.org/download/\n2. Install PostgreSql with the default settings.  The default connection string uses the following credentials:\n  1. Username: postgres\n  2. Password: postgres\n3. A custom app.config file can be used and needs to be placed in the same folder as the dll\n\nor run postgres in docker\n\n```\ndocker run -d --rm --name=akka-postgres-db -p 5432:5432 -l deployer=akkadotnet -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres postgres:9.6\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakkadotnet%2Fakka.persistence.postgresql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakkadotnet%2Fakka.persistence.postgresql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakkadotnet%2Fakka.persistence.postgresql/lists"}