99
1010use Closure ;
1111use OCP \DB \ISchemaWrapper ;
12+ use OCP \IDBConnection ;
1213use OCP \Migration \IOutput ;
1314use OCP \Migration \SimpleMigrationStep ;
1415
1516/**
1617 * Auto-generated migration step: Please modify to your needs!
1718 */
1819class Version2060Date20200302131958 extends SimpleMigrationStep {
20+
21+ public function __construct (
22+ private IDBConnection $ connection ,
23+ ) {
24+ }
25+
26+ public function preSchemaChange (IOutput $ output , Closure $ schemaClosure , array $ options ) {
27+ /** @var ISchemaWrapper $schema */
28+ $ schema = $ schemaClosure ();
29+
30+ if ($ schema ->hasTable ('richdocuments_wopi ' )) {
31+ $ qb = $ this ->connection ->getQueryBuilder ();
32+ $ qb ->delete ('richdocuments_wopi ' );
33+ $ qb ->executeStatement ();
34+ }
35+ }
36+
1937 /**
2038 * @param IOutput $output
2139 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
@@ -26,6 +44,10 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
2644 /** @var ISchemaWrapper $schema */
2745 $ schema = $ schemaClosure ();
2846
47+ if ($ schema ->hasTable ('richdocuments_wopi ' )) {
48+ $ schema ->dropTable ('richdocuments_wopi ' );
49+ }
50+
2951 if (!$ schema ->hasTable ('richdocuments_wopi ' )) {
3052 $ table = $ schema ->createTable ('richdocuments_wopi ' );
3153 $ table ->addColumn ('id ' , 'bigint ' , [
0 commit comments