| | 1 | | using Microsoft.EntityFrameworkCore.Migrations; |
| | 2 | |
|
| | 3 | | #nullable disable |
| | 4 | |
|
| | 5 | | namespace NLightning.Infrastructure.Persistence.Sqlite.Migrations |
| | 6 | | { |
| | 7 | | /// <inheritdoc /> |
| | 8 | | public partial class Initial : Migration |
| | 9 | | { |
| | 10 | | /// <inheritdoc /> |
| | 11 | | protected override void Up(MigrationBuilder migrationBuilder) |
| | 12 | | { |
| 0 | 13 | | migrationBuilder.CreateTable( |
| 0 | 14 | | name: "Channels", |
| 0 | 15 | | columns: table => new |
| 0 | 16 | | { |
| 0 | 17 | | ChannelId = table.Column<byte[]>(type: "BLOB", nullable: false), |
| 0 | 18 | | FundingCreatedAtBlockHeight = table.Column<uint>(type: "INTEGER", nullable: false), |
| 0 | 19 | | FundingTxId = table.Column<byte[]>(type: "BLOB", nullable: false), |
| 0 | 20 | | FundingOutputIndex = table.Column<uint>(type: "INTEGER", nullable: false), |
| 0 | 21 | | FundingAmountSatoshis = table.Column<long>(type: "INTEGER", nullable: false), |
| 0 | 22 | | IsInitiator = table.Column<bool>(type: "INTEGER", nullable: false), |
| 0 | 23 | | RemoteNodeId = table.Column<byte[]>(type: "BLOB", nullable: false), |
| 0 | 24 | | LocalNextHtlcId = table.Column<ulong>(type: "INTEGER", nullable: false), |
| 0 | 25 | | RemoteNextHtlcId = table.Column<ulong>(type: "INTEGER", nullable: false), |
| 0 | 26 | | LocalRevocationNumber = table.Column<ulong>(type: "INTEGER", nullable: false), |
| 0 | 27 | | RemoteRevocationNumber = table.Column<ulong>(type: "INTEGER", nullable: false), |
| 0 | 28 | | LastSentSignature = table.Column<byte[]>(type: "BLOB", nullable: true), |
| 0 | 29 | | LastReceivedSignature = table.Column<byte[]>(type: "BLOB", nullable: true), |
| 0 | 30 | | State = table.Column<byte>(type: "INTEGER", nullable: false), |
| 0 | 31 | | Version = table.Column<byte>(type: "INTEGER", nullable: false), |
| 0 | 32 | | LocalBalanceSatoshis = table.Column<decimal>(type: "TEXT", nullable: false), |
| 0 | 33 | | RemoteBalanceSatoshis = table.Column<decimal>(type: "TEXT", nullable: false) |
| 0 | 34 | | }, |
| 0 | 35 | | constraints: table => |
| 0 | 36 | | { |
| 0 | 37 | | table.PrimaryKey("PK_Channels", x => x.ChannelId); |
| 0 | 38 | | }); |
| | 39 | |
|
| 0 | 40 | | migrationBuilder.CreateTable( |
| 0 | 41 | | name: "ChannelConfigs", |
| 0 | 42 | | columns: table => new |
| 0 | 43 | | { |
| 0 | 44 | | ChannelId = table.Column<byte[]>(type: "BLOB", nullable: false), |
| 0 | 45 | | MinimumDepth = table.Column<uint>(type: "INTEGER", nullable: false), |
| 0 | 46 | | ToSelfDelay = table.Column<ushort>(type: "INTEGER", nullable: false), |
| 0 | 47 | | MaxAcceptedHtlcs = table.Column<ushort>(type: "INTEGER", nullable: false), |
| 0 | 48 | | LocalDustLimitAmountSats = table.Column<long>(type: "INTEGER", nullable: false), |
| 0 | 49 | | RemoteDustLimitAmountSats = table.Column<long>(type: "INTEGER", nullable: false), |
| 0 | 50 | | HtlcMinimumMsat = table.Column<ulong>(type: "INTEGER", nullable: false), |
| 0 | 51 | | ChannelReserveAmountSats = table.Column<long>(type: "INTEGER", nullable: true), |
| 0 | 52 | | MaxHtlcAmountInFlight = table.Column<ulong>(type: "INTEGER", nullable: false), |
| 0 | 53 | | FeeRatePerKwSatoshis = table.Column<long>(type: "INTEGER", nullable: false), |
| 0 | 54 | | OptionAnchorOutputs = table.Column<bool>(type: "INTEGER", nullable: false), |
| 0 | 55 | | LocalUpfrontShutdownScript = table.Column<byte[]>(type: "BLOB", nullable: true), |
| 0 | 56 | | RemoteUpfrontShutdownScript = table.Column<byte[]>(type: "BLOB", nullable: true), |
| 0 | 57 | | UseScidAlias = table.Column<byte>(type: "INTEGER", nullable: false) |
| 0 | 58 | | }, |
| 0 | 59 | | constraints: table => |
| 0 | 60 | | { |
| 0 | 61 | | table.PrimaryKey("PK_ChannelConfigs", x => x.ChannelId); |
| 0 | 62 | | table.ForeignKey( |
| 0 | 63 | | name: "FK_ChannelConfigs_Channels_ChannelId", |
| 0 | 64 | | column: x => x.ChannelId, |
| 0 | 65 | | principalTable: "Channels", |
| 0 | 66 | | principalColumn: "ChannelId", |
| 0 | 67 | | onDelete: ReferentialAction.Cascade); |
| 0 | 68 | | }); |
| | 69 | |
|
| 0 | 70 | | migrationBuilder.CreateTable( |
| 0 | 71 | | name: "ChannelKeySets", |
| 0 | 72 | | columns: table => new |
| 0 | 73 | | { |
| 0 | 74 | | ChannelId = table.Column<byte[]>(type: "BLOB", nullable: false), |
| 0 | 75 | | IsLocal = table.Column<bool>(type: "INTEGER", nullable: false), |
| 0 | 76 | | FundingPubKey = table.Column<byte[]>(type: "BLOB", nullable: false), |
| 0 | 77 | | RevocationBasepoint = table.Column<byte[]>(type: "BLOB", nullable: false), |
| 0 | 78 | | PaymentBasepoint = table.Column<byte[]>(type: "BLOB", nullable: false), |
| 0 | 79 | | DelayedPaymentBasepoint = table.Column<byte[]>(type: "BLOB", nullable: false), |
| 0 | 80 | | HtlcBasepoint = table.Column<byte[]>(type: "BLOB", nullable: false), |
| 0 | 81 | | CurrentPerCommitmentIndex = table.Column<ulong>(type: "INTEGER", nullable: false), |
| 0 | 82 | | CurrentPerCommitmentPoint = table.Column<byte[]>(type: "BLOB", nullable: false), |
| 0 | 83 | | LastRevealedPerCommitmentSecret = table.Column<byte[]>(type: "BLOB", nullable: true), |
| 0 | 84 | | KeyIndex = table.Column<uint>(type: "INTEGER", nullable: false) |
| 0 | 85 | | }, |
| 0 | 86 | | constraints: table => |
| 0 | 87 | | { |
| 0 | 88 | | table.PrimaryKey("PK_ChannelKeySets", x => new { x.ChannelId, x.IsLocal }); |
| 0 | 89 | | table.ForeignKey( |
| 0 | 90 | | name: "FK_ChannelKeySets_Channels_ChannelId", |
| 0 | 91 | | column: x => x.ChannelId, |
| 0 | 92 | | principalTable: "Channels", |
| 0 | 93 | | principalColumn: "ChannelId", |
| 0 | 94 | | onDelete: ReferentialAction.Cascade); |
| 0 | 95 | | }); |
| | 96 | |
|
| 0 | 97 | | migrationBuilder.CreateTable( |
| 0 | 98 | | name: "Htlcs", |
| 0 | 99 | | columns: table => new |
| 0 | 100 | | { |
| 0 | 101 | | ChannelId = table.Column<byte[]>(type: "BLOB", nullable: false), |
| 0 | 102 | | HtlcId = table.Column<ulong>(type: "INTEGER", nullable: false), |
| 0 | 103 | | Direction = table.Column<byte>(type: "INTEGER", nullable: false), |
| 0 | 104 | | AmountMsat = table.Column<ulong>(type: "INTEGER", nullable: false), |
| 0 | 105 | | PaymentHash = table.Column<byte[]>(type: "BLOB", nullable: false), |
| 0 | 106 | | PaymentPreimage = table.Column<byte[]>(type: "BLOB", nullable: true), |
| 0 | 107 | | CltvExpiry = table.Column<uint>(type: "INTEGER", nullable: false), |
| 0 | 108 | | State = table.Column<byte>(type: "INTEGER", nullable: false), |
| 0 | 109 | | ObscuredCommitmentNumber = table.Column<ulong>(type: "INTEGER", nullable: false), |
| 0 | 110 | | AddMessageBytes = table.Column<byte[]>(type: "BLOB", nullable: false), |
| 0 | 111 | | Signature = table.Column<byte[]>(type: "BLOB", nullable: true) |
| 0 | 112 | | }, |
| 0 | 113 | | constraints: table => |
| 0 | 114 | | { |
| 0 | 115 | | table.PrimaryKey("PK_Htlcs", x => new { x.ChannelId, x.HtlcId, x.Direction }); |
| 0 | 116 | | table.ForeignKey( |
| 0 | 117 | | name: "FK_Htlcs_Channels_ChannelId", |
| 0 | 118 | | column: x => x.ChannelId, |
| 0 | 119 | | principalTable: "Channels", |
| 0 | 120 | | principalColumn: "ChannelId", |
| 0 | 121 | | onDelete: ReferentialAction.Cascade); |
| 0 | 122 | | }); |
| 0 | 123 | | } |
| | 124 | |
|
| | 125 | | /// <inheritdoc /> |
| | 126 | | protected override void Down(MigrationBuilder migrationBuilder) |
| | 127 | | { |
| 0 | 128 | | migrationBuilder.DropTable( |
| 0 | 129 | | name: "ChannelConfigs"); |
| | 130 | |
|
| 0 | 131 | | migrationBuilder.DropTable( |
| 0 | 132 | | name: "ChannelKeySets"); |
| | 133 | |
|
| 0 | 134 | | migrationBuilder.DropTable( |
| 0 | 135 | | name: "Htlcs"); |
| | 136 | |
|
| 0 | 137 | | migrationBuilder.DropTable( |
| 0 | 138 | | name: "Channels"); |
| 0 | 139 | | } |
| | 140 | | } |
| | 141 | | } |