(options?: {
readonly prefix?: string | undefined
})
| 823 | // ------------------------------------------------------------------------------------------------- |
| 824 | |
| 825 | const migrations = (options?: { |
| 826 | readonly prefix?: string | undefined |
| 827 | }) => { |
| 828 | const prefix = options?.prefix ?? "cluster" |
| 829 | const table = (name: string) => `${prefix}_${name}` |
| 830 | const messagesTable = table("messages") |
| 831 | const repliesTable = table("replies") |
| 832 | |
| 833 | return Migrator.fromRecord({ |
| 834 | "0001_create_tables": Effect.gen(function*() { |
| 835 | const sql = (yield* SqlClient.SqlClient).withoutTransforms() |
| 836 | const messagesTableSql = sql(messagesTable) |
| 837 | const repliesTableSql = sql(repliesTable) |
| 838 | |
| 839 | yield* sql.onDialectOrElse({ |
| 840 | mssql: () => |
| 841 | sql` |
| 842 | IF OBJECT_ID(N'${messagesTableSql}', N'U') IS NULL |
| 843 | CREATE TABLE ${messagesTableSql} ( |
| 844 | id BIGINT PRIMARY KEY, |
| 845 | rowid BIGINT IDENTITY(1,1), |
| 846 | message_id VARCHAR(255), |
| 847 | shard_id VARCHAR(50) NOT NULL, |
| 848 | entity_type VARCHAR(150) NOT NULL, |
| 849 | entity_id VARCHAR(255) NOT NULL, |
| 850 | kind INT NOT NULL, |
| 851 | tag VARCHAR(50), |
| 852 | payload TEXT, |
| 853 | headers TEXT, |
| 854 | trace_id VARCHAR(32), |
| 855 | span_id VARCHAR(16), |
| 856 | sampled BIT, |
| 857 | processed BIT NOT NULL DEFAULT 0, |
| 858 | request_id BIGINT NOT NULL, |
| 859 | reply_id BIGINT, |
| 860 | last_reply_id BIGINT, |
| 861 | last_read DATETIME, |
| 862 | deliver_at BIGINT, |
| 863 | UNIQUE (message_id) |
| 864 | ) |
| 865 | `, |
| 866 | mysql: () => |
| 867 | sql` |
| 868 | CREATE TABLE IF NOT EXISTS ${messagesTableSql} ( |
| 869 | id BIGINT NOT NULL, |
| 870 | rowid BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, |
| 871 | message_id VARCHAR(255), |
| 872 | shard_id VARCHAR(50) NOT NULL, |
| 873 | entity_type VARCHAR(150) NOT NULL, |
| 874 | entity_id VARCHAR(255) NOT NULL, |
| 875 | kind INT NOT NULL, |
| 876 | tag VARCHAR(50), |
| 877 | payload TEXT, |
| 878 | headers TEXT, |
| 879 | trace_id VARCHAR(32), |
| 880 | span_id VARCHAR(16), |
| 881 | sampled BOOLEAN, |
| 882 | processed BOOLEAN NOT NULL DEFAULT FALSE, |
no test coverage detected