(options?: {
readonly prefix?: string | undefined
})
| 643 | // ------------------------------------------------------------------------------------------------- |
| 644 | |
| 645 | const migrations = (options?: { |
| 646 | readonly prefix?: string | undefined |
| 647 | }) => { |
| 648 | const prefix = options?.prefix ?? "cluster" |
| 649 | const table = (name: string) => `${prefix}_${name}` |
| 650 | const messagesTable = table("messages") |
| 651 | const repliesTable = table("replies") |
| 652 | |
| 653 | return Migrator.fromRecord({ |
| 654 | "0001_create_tables": Effect.gen(function*() { |
| 655 | const sql = (yield* SqlClient.SqlClient).withoutTransforms() |
| 656 | const messagesTableSql = sql(messagesTable) |
| 657 | const repliesTableSql = sql(repliesTable) |
| 658 | |
| 659 | yield* sql.onDialectOrElse({ |
| 660 | mssql: () => |
| 661 | sql` |
| 662 | IF OBJECT_ID(N'${messagesTableSql}', N'U') IS NULL |
| 663 | CREATE TABLE ${messagesTableSql} ( |
| 664 | id BIGINT PRIMARY KEY, |
| 665 | rowid BIGINT IDENTITY(1,1), |
| 666 | message_id VARCHAR(255), |
| 667 | shard_id VARCHAR(50) NOT NULL, |
| 668 | entity_type VARCHAR(150) NOT NULL, |
| 669 | entity_id VARCHAR(255) NOT NULL, |
| 670 | kind INT NOT NULL, |
| 671 | tag VARCHAR(50), |
| 672 | payload TEXT, |
| 673 | headers TEXT, |
| 674 | trace_id VARCHAR(32), |
| 675 | span_id VARCHAR(16), |
| 676 | sampled BIT, |
| 677 | processed BIT NOT NULL DEFAULT 0, |
| 678 | request_id BIGINT NOT NULL, |
| 679 | reply_id BIGINT, |
| 680 | last_reply_id BIGINT, |
| 681 | last_read DATETIME, |
| 682 | deliver_at BIGINT, |
| 683 | UNIQUE (message_id) |
| 684 | ) |
| 685 | `, |
| 686 | mysql: () => |
| 687 | sql` |
| 688 | CREATE TABLE IF NOT EXISTS ${messagesTableSql} ( |
| 689 | id BIGINT NOT NULL, |
| 690 | rowid BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, |
| 691 | message_id VARCHAR(255), |
| 692 | shard_id VARCHAR(50) NOT NULL, |
| 693 | entity_type VARCHAR(150) NOT NULL, |
| 694 | entity_id VARCHAR(255) NOT NULL, |
| 695 | kind INT NOT NULL, |
| 696 | tag VARCHAR(50), |
| 697 | payload TEXT, |
| 698 | headers TEXT, |
| 699 | trace_id VARCHAR(32), |
| 700 | span_id VARCHAR(16), |
| 701 | sampled BOOLEAN, |
| 702 | processed BOOLEAN NOT NULL DEFAULT FALSE, |
no test coverage detected