|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * ownCloud - sciencemesh |
| 4 | + * |
| 5 | + * This file is licensed under the MIT License. See the LICENCE file. |
| 6 | + * @license MIT |
| 7 | + * @copyright Sciencemesh 2020 - 2023 |
| 8 | + * |
| 9 | + * @author Mohammad Mahdi Baghbani Pourvahid <mahdi-baghbani@azadehafzar.ir> |
| 10 | + */ |
| 11 | + |
| 12 | +namespace OCA\ScienceMesh\Migrations; |
| 13 | + |
| 14 | +use Doctrine\DBAL\Schema\Schema; |
| 15 | +use OCP\Migration\ISchemaMigration; |
| 16 | + |
| 17 | +/** Creates initial schema */ |
| 18 | +class Version20230916 implements ISchemaMigration |
| 19 | +{ |
| 20 | + public function changeSchema(Schema $schema, array $options) |
| 21 | + { |
| 22 | + $prefix = $options["tablePrefix"]; |
| 23 | + |
| 24 | + // ocm_received_shares table. |
| 25 | + if (!$schema->hasTable("{$prefix}sciencemesh_ocm_received_shares")) { |
| 26 | + $table = $schema->createTable("{$prefix}sciencemesh_ocm_received_shares"); |
| 27 | + |
| 28 | + $table->addColumn("id", "bigint", [ |
| 29 | + "autoincrement" => true, |
| 30 | + "unsigned" => true, |
| 31 | + "notnull" => true, |
| 32 | + "length" => 11, |
| 33 | + ]); |
| 34 | + |
| 35 | + $table->addColumn("share_external_id", "bigint", [ |
| 36 | + "unsigned" => false, |
| 37 | + "notnull" => true, |
| 38 | + "length" => 11, |
| 39 | + ]); |
| 40 | + |
| 41 | + $table->addColumn("name", "string", [ |
| 42 | + "length" => 255, |
| 43 | + "notnull" => true, |
| 44 | + "comment" => "Original name on the remote server" |
| 45 | + ]); |
| 46 | + |
| 47 | + $table->addColumn("share_with", "string", [ |
| 48 | + "length" => 255, |
| 49 | + "notnull" => true, |
| 50 | + ]); |
| 51 | + |
| 52 | + $table->addColumn("owner", "string", [ |
| 53 | + "length" => 255, |
| 54 | + "notnull" => true, |
| 55 | + ]); |
| 56 | + |
| 57 | + $table->addColumn("initiator", "string", [ |
| 58 | + "length" => 255, |
| 59 | + "notnull" => true, |
| 60 | + ]); |
| 61 | + |
| 62 | + $table->addColumn("ctime", "bigint", [ |
| 63 | + "unsigned" => false, |
| 64 | + "notnull" => true, |
| 65 | + "length" => 11, |
| 66 | + ]); |
| 67 | + |
| 68 | + $table->addColumn("mtime", "bigint", [ |
| 69 | + "unsigned" => false, |
| 70 | + "notnull" => true, |
| 71 | + "length" => 11, |
| 72 | + ]); |
| 73 | + |
| 74 | + $table->addColumn("expiration", "bigint", [ |
| 75 | + "unsigned" => false, |
| 76 | + "notnull" => false, |
| 77 | + "default" => null, |
| 78 | + "length" => 11, |
| 79 | + ]); |
| 80 | + |
| 81 | + $table->addColumn("remote_share_id", "string", [ |
| 82 | + "length" => 255, |
| 83 | + "notnull" => false, |
| 84 | + "default" => null, |
| 85 | + "comment" => "share ID at the remote server" |
| 86 | + ]); |
| 87 | + |
| 88 | + $table->setPrimaryKey(["id"]); |
| 89 | + |
| 90 | + $table->addUniqueIndex( |
| 91 | + ["share_external_id"], |
| 92 | + "sm_ocm_rx_ex_id_idx" |
| 93 | + ); |
| 94 | + $table->addUniqueIndex( |
| 95 | + ["share_with"], |
| 96 | + "sm_ocm_rx_sh_w_idx" |
| 97 | + ); |
| 98 | + } |
| 99 | + |
| 100 | + // ocm_protocol_transfer table. |
| 101 | + if (!$schema->hasTable("{$prefix}sciencemesh_ocm_received_share_protocol_transfer")) { |
| 102 | + $table = $schema->createTable("{$prefix}sciencemesh_ocm_received_share_protocol_transfer"); |
| 103 | + |
| 104 | + $table->addColumn("ocm_received_share_id", "bigint", [ |
| 105 | + "unsigned" => true, |
| 106 | + "notnull" => true, |
| 107 | + "length" => 11, |
| 108 | + ]); |
| 109 | + |
| 110 | + $table->addColumn("source_uri", "string", [ |
| 111 | + "length" => 255, |
| 112 | + "notnull" => true, |
| 113 | + ]); |
| 114 | + |
| 115 | + $table->addColumn("shared_secret", "string", [ |
| 116 | + "length" => 255, |
| 117 | + "notnull" => true, |
| 118 | + ]); |
| 119 | + |
| 120 | + $table->addColumn("size", "bigint", [ |
| 121 | + "unsigned" => false, |
| 122 | + "notnull" => true, |
| 123 | + "length" => 11, |
| 124 | + ]); |
| 125 | + |
| 126 | + $table->addUniqueIndex( |
| 127 | + ["ocm_received_share_id"], |
| 128 | + "sm_ocm_rx_share_id_tx_idx" |
| 129 | + ); |
| 130 | + } |
| 131 | + |
| 132 | + // ocm_protocol_webapp table. |
| 133 | + if (!$schema->hasTable("{$prefix}sciencemesh_ocm_received_share_protocol_webapp")) { |
| 134 | + $table = $schema->createTable("{$prefix}sciencemesh_ocm_received_share_protocol_webapp"); |
| 135 | + |
| 136 | + $table->addColumn("ocm_received_share_id", "bigint", [ |
| 137 | + "unsigned" => true, |
| 138 | + "notnull" => true, |
| 139 | + "length" => 11, |
| 140 | + ]); |
| 141 | + |
| 142 | + $table->addColumn("uri_template", "string", [ |
| 143 | + "length" => 255, |
| 144 | + "notnull" => true, |
| 145 | + ]); |
| 146 | + |
| 147 | + $table->addColumn("view_mode", "bigint", [ |
| 148 | + "unsigned" => false, |
| 149 | + "notnull" => true, |
| 150 | + "length" => 11, |
| 151 | + ]); |
| 152 | + |
| 153 | + $table->addUniqueIndex( |
| 154 | + ["ocm_received_share_id"], |
| 155 | + "sm_ocm_rx_share_id_app_idx" |
| 156 | + ); |
| 157 | + } |
| 158 | + |
| 159 | + // ocm_protocol_webdav table. |
| 160 | + if (!$schema->hasTable("{$prefix}sciencemesh_ocm_received_share_protocol_webdav")) { |
| 161 | + $table = $schema->createTable("{$prefix}sciencemesh_ocm_received_share_protocol_webdav"); |
| 162 | + |
| 163 | + $table->addColumn("ocm_received_share_id", "bigint", [ |
| 164 | + "unsigned" => true, |
| 165 | + "notnull" => true, |
| 166 | + "length" => 11, |
| 167 | + ]); |
| 168 | + |
| 169 | + $table->addColumn("uri", "string", [ |
| 170 | + "length" => 255, |
| 171 | + "notnull" => true, |
| 172 | + ]); |
| 173 | + |
| 174 | + $table->addColumn("shared_secret", "string", [ |
| 175 | + "length" => 255, |
| 176 | + "notnull" => true, |
| 177 | + ]); |
| 178 | + |
| 179 | + $table->addColumn("permissions", "bigint", [ |
| 180 | + "unsigned" => false, |
| 181 | + "notnull" => true, |
| 182 | + "length" => 11, |
| 183 | + ]); |
| 184 | + |
| 185 | + $table->addUniqueIndex( |
| 186 | + ["ocm_received_share_id"], |
| 187 | + "sm_ocm_rx_share_id_dav_idx" |
| 188 | + ); |
| 189 | + } |
| 190 | + } |
| 191 | +} |
0 commit comments