1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,264 @@ |
1 |
+<?php |
|
2 |
+/** |
|
3 |
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com> |
|
4 |
+ * |
|
5 |
+ * @author Double Bastion LLC |
|
6 |
+ * |
|
7 |
+ * @license GNU AGPL version 3 or any later version |
|
8 |
+ * |
|
9 |
+ * This program is free software; you can redistribute it and/or |
|
10 |
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
11 |
+ * License as published by the Free Software Foundation; either |
|
12 |
+ * version 3 of the License, or any later version. |
|
13 |
+ * |
|
14 |
+ * This program is distributed in the hope that it will be useful, |
|
15 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17 |
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
|
18 |
+ * |
|
19 |
+ * You should have received a copy of the GNU Affero General Public |
|
20 |
+ * License along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
21 |
+ * |
|
22 |
+ */ |
|
23 |
+ |
|
24 |
+declare(strict_types=1); |
|
25 |
+ |
|
26 |
+namespace OCA\SMSRelentless\Migration; |
|
27 |
+ |
|
28 |
+use Closure; |
|
29 |
+use OCP\DB\Types; |
|
30 |
+use Doctrine\DBAL\Types\Type; |
|
31 |
+use OCP\DB\ISchemaWrapper; |
|
32 |
+use OCP\Migration\IOutput; |
|
33 |
+use OCP\Migration\SimpleMigrationStep; |
|
34 |
+ |
|
35 |
+ |
|
36 |
+class Version113Date20221201044315 extends SimpleMigrationStep { |
|
37 |
+ /** |
|
38 |
+ * @param IOutput $output |
|
39 |
+ * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
40 |
+ * @param array $options |
|
41 |
+ * @return null|ISchemaWrapper |
|
42 |
+ */ |
|
43 |
+ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
44 |
+ /** @var ISchemaWrapper $schema */ |
|
45 |
+ $schema = $schemaClosure(); |
|
46 |
+ |
|
47 |
+ if (!$schema->hasTable('sms_relent_settings')) { |
|
48 |
+ $table = $schema->createTable('sms_relent_settings'); |
|
49 |
+ $table->addColumn('id', 'bigint', [ |
|
50 |
+ 'autoincrement' => true, |
|
51 |
+ 'notnull' => true, |
|
52 |
+ 'length' => 11, |
|
53 |
+ 'unsigned' => true, |
|
54 |
+ ]); |
|
55 |
+ $table->addColumn('user_id', 'string', [ |
|
56 |
+ 'notnull' => true, |
|
57 |
+ 'length' => 128, |
|
58 |
+ ]); |
|
59 |
+ $table->addColumn('telapi_key', 'string', [ |
|
60 |
+ 'notnull' => true, |
|
61 |
+ 'length' => 512, |
|
62 |
+ ]); |
|
63 |
+ $table->addColumn('tel_pub_key', 'string', [ |
|
64 |
+ 'notnull' => true, |
|
65 |
+ 'length' => 512, |
|
66 |
+ ]); |
|
67 |
+ $table->addColumn('telapi_url_rec', 'string', [ |
|
68 |
+ 'notnull' => true, |
|
69 |
+ 'length' => 512, |
|
70 |
+ ]); |
|
71 |
+ $table->addColumn('telapi_url', 'string', [ |
|
72 |
+ 'notnull' => true, |
|
73 |
+ 'length' => 512, |
|
74 |
+ ]); |
|
75 |
+ $table->addColumn('messaging_profile_id', 'string', [ |
|
76 |
+ 'notnull' => true, |
|
77 |
+ 'length' => 512, |
|
78 |
+ ]); |
|
79 |
+ $table->addColumn('nexapi_key', 'string', [ |
|
80 |
+ 'notnull' => true, |
|
81 |
+ 'length' => 512, |
|
82 |
+ ]); |
|
83 |
+ $table->addColumn('nexapi_secret', 'string', [ |
|
84 |
+ 'notnull' => true, |
|
85 |
+ 'length' => 512, |
|
86 |
+ ]); |
|
87 |
+ $table->addColumn('nexapi_url_rec', 'string', [ |
|
88 |
+ 'notnull' => true, |
|
89 |
+ 'length' => 512, |
|
90 |
+ ]); |
|
91 |
+ $table->addColumn('nexapi_url', 'string', [ |
|
92 |
+ 'notnull' => true, |
|
93 |
+ 'length' => 512, |
|
94 |
+ ]); |
|
95 |
+ $table->addColumn('twilapi_key', 'string', [ |
|
96 |
+ 'notnull' => true, |
|
97 |
+ 'length' => 512, |
|
98 |
+ ]); |
|
99 |
+ $table->addColumn('twilapi_secret', 'string', [ |
|
100 |
+ 'notnull' => true, |
|
101 |
+ 'length' => 512, |
|
102 |
+ ]); |
|
103 |
+ $table->addColumn('twilapi_url_rec', 'string', [ |
|
104 |
+ 'notnull' => true, |
|
105 |
+ 'length' => 512, |
|
106 |
+ ]); |
|
107 |
+ $table->addColumn('twilapi_url', 'string', [ |
|
108 |
+ 'notnull' => true, |
|
109 |
+ 'length' => 512, |
|
110 |
+ ]); |
|
111 |
+ $table->addColumn('flowapi_key', 'string', [ |
|
112 |
+ 'notnull' => true, |
|
113 |
+ 'length' => 512, |
|
114 |
+ ]); |
|
115 |
+ $table->addColumn('flowapi_secret', 'string', [ |
|
116 |
+ 'notnull' => true, |
|
117 |
+ 'length' => 512, |
|
118 |
+ ]); |
|
119 |
+ $table->addColumn('flowapi_url_rec', 'string', [ |
|
120 |
+ 'notnull' => true, |
|
121 |
+ 'length' => 512, |
|
122 |
+ ]); |
|
123 |
+ $table->addColumn('flowapi_url', 'string', [ |
|
124 |
+ 'notnull' => true, |
|
125 |
+ 'length' => 512, |
|
126 |
+ ]); |
|
127 |
+ $table->addColumn('tel_sender_name', 'string', [ |
|
128 |
+ 'notnull' => false, |
|
129 |
+ 'length' => 48, |
|
130 |
+ 'default' => '', |
|
131 |
+ ]); |
|
132 |
+ $table->addColumn('nex_sender_name', 'string', [ |
|
133 |
+ 'notnull' => false, |
|
134 |
+ 'length' => 48, |
|
135 |
+ 'default' => '', |
|
136 |
+ ]); |
|
137 |
+ $table->addColumn('twil_sender_name', 'string', [ |
|
138 |
+ 'notnull' => false, |
|
139 |
+ 'length' => 48, |
|
140 |
+ 'default' => '', |
|
141 |
+ ]); |
|
142 |
+ $table->addColumn('flow_sender_name', 'string', [ |
|
143 |
+ 'notnull' => false, |
|
144 |
+ 'length' => 48, |
|
145 |
+ 'default' => '', |
|
146 |
+ ]); |
|
147 |
+ $table->addColumn('messagesperpage', 'integer', [ |
|
148 |
+ 'notnull' => false, |
|
149 |
+ 'length' => 11, |
|
150 |
+ 'unsigned' => true, |
|
151 |
+ ]); |
|
152 |
+ $table->addColumn('get_notify', 'smallint', [ |
|
153 |
+ 'notnull' => false, |
|
154 |
+ 'length' => 1, |
|
155 |
+ ]); |
|
156 |
+ $table->addColumn('notification_email', 'string', [ |
|
157 |
+ 'notnull' => false, |
|
158 |
+ 'length' => 512, |
|
159 |
+ 'default' => '', |
|
160 |
+ ]); |
|
161 |
+ $table->addColumn('getsmsinemail', 'smallint', [ |
|
162 |
+ 'notnull' => false, |
|
163 |
+ 'length' => 1, |
|
164 |
+ ]); |
|
165 |
+ $table->setPrimaryKey(['id']); |
|
166 |
+ $table->addUniqueIndex(['id']); |
|
167 |
+ |
|
168 |
+ } |
|
169 |
+ |
|
170 |
+ if (!$schema->hasTable('sms_relent_received')) { |
|
171 |
+ $table = $schema->createTable('sms_relent_received'); |
|
172 |
+ $table->addColumn('id', 'bigint', [ |
|
173 |
+ 'autoincrement' => true, |
|
174 |
+ 'notnull' => true, |
|
175 |
+ 'length' => 11, |
|
176 |
+ 'unsigned' => true, |
|
177 |
+ ]); |
|
178 |
+ $table->addColumn('user_id', 'string', [ |
|
179 |
+ 'notnull' => true, |
|
180 |
+ 'length' => 64, |
|
181 |
+ ]); |
|
182 |
+ $table->addColumn('message_id', 'string', [ |
|
183 |
+ 'notnull' => true, |
|
184 |
+ 'length' => 512, |
|
185 |
+ ]); |
|
186 |
+ $table->addColumn('date', 'datetime', [ |
|
187 |
+ 'notnull' => true, |
|
188 |
+ ]); |
|
189 |
+ $table->addColumn('from', 'string', [ |
|
190 |
+ 'notnull' => true, |
|
191 |
+ 'length' => 128, |
|
192 |
+ ]); |
|
193 |
+ $table->addColumn('to', 'string', [ |
|
194 |
+ 'notnull' => true, |
|
195 |
+ 'length' => 128, |
|
196 |
+ ]); |
|
197 |
+ $table->addColumn('message', 'text', [ |
|
198 |
+ 'notnull' => false, |
|
199 |
+ 'default' => '', |
|
200 |
+ ]); |
|
201 |
+ $table->setPrimaryKey(['id']); |
|
202 |
+ $table->addUniqueIndex(['id']); |
|
203 |
+ |
|
204 |
+ } |
|
205 |
+ |
|
206 |
+ if (!$schema->hasTable('sms_relent_sent')) { |
|
207 |
+ $table = $schema->createTable('sms_relent_sent'); |
|
208 |
+ $table->addColumn('id', 'bigint', [ |
|
209 |
+ 'autoincrement' => true, |
|
210 |
+ 'notnull' => true, |
|
211 |
+ 'length' => 11, |
|
212 |
+ 'unsigned' => true, |
|
213 |
+ ]); |
|
214 |
+ $table->addColumn('user_id', 'string', [ |
|
215 |
+ 'notnull' => true, |
|
216 |
+ 'length' => 64, |
|
217 |
+ ]); |
|
218 |
+ $table->addColumn('message_id', 'string', [ |
|
219 |
+ 'notnull' => true, |
|
220 |
+ 'length' => 512, |
|
221 |
+ ]); |
|
222 |
+ $table->addColumn('date', 'datetime', [ |
|
223 |
+ 'notnull' => true, |
|
224 |
+ ]); |
|
225 |
+ $table->addColumn('from', 'string', [ |
|
226 |
+ 'notnull' => true, |
|
227 |
+ 'length' => 128, |
|
228 |
+ ]); |
|
229 |
+ $table->addColumn('to', 'string', [ |
|
230 |
+ 'notnull' => true, |
|
231 |
+ 'length' => 128, |
|
232 |
+ ]); |
|
233 |
+ $table->addColumn('network ', 'string', [ |
|
234 |
+ 'notnull' => false, |
|
235 |
+ 'length' => 64, |
|
236 |
+ 'default' => '', |
|
237 |
+ ]); |
|
238 |
+ $table->addColumn('price', 'string', [ |
|
239 |
+ 'notnull' => false, |
|
240 |
+ 'length' => 64, |
|
241 |
+ 'default' => '', |
|
242 |
+ ]); |
|
243 |
+ $table->addColumn('status', 'string', [ |
|
244 |
+ 'notnull' => false, |
|
245 |
+ 'length' => 512, |
|
246 |
+ 'default' => '', |
|
247 |
+ ]); |
|
248 |
+ $table->addColumn('deliveryreceipt', 'string', [ |
|
249 |
+ 'notnull' => false, |
|
250 |
+ 'length' => 64, |
|
251 |
+ 'default' => '', |
|
252 |
+ ]); |
|
253 |
+ $table->addColumn('message', 'text', [ |
|
254 |
+ 'notnull' => false, |
|
255 |
+ 'default' => '', |
|
256 |
+ ]); |
|
257 |
+ $table->setPrimaryKey(['id']); |
|
258 |
+ $table->addUniqueIndex(['id']); |
|
259 |
+ |
|
260 |
+ } |
|
261 |
+ |
|
262 |
+ return $schema; |
|
263 |
+ } |
|
264 |
+} |