4
4
5
5
namespace Atk4 \Data \Schema ;
6
6
7
- use Atk4 \Core \Exception ;
7
+ use Atk4 \Data \Exception ;
8
8
use Atk4 \Data \Field ;
9
9
use Atk4 \Data \FieldSqlExpression ;
10
10
use Atk4 \Data \Model ;
@@ -98,7 +98,9 @@ public function create(): self
98
98
99
99
public function drop (): self
100
100
{
101
- $ this ->getSchemaManager ()->dropTable ($ this ->getDatabasePlatform ()->quoteSingleIdentifier ($ this ->table ->getName ()));
101
+ $ this ->getSchemaManager ()
102
+ ->dropTable ($ this ->getDatabasePlatform ()->quoteSingleIdentifier ($ this ->table ->getName ()));
103
+
102
104
$ this ->createdTableNames = array_diff ($ this ->createdTableNames , [$ this ->table ->getName ()]);
103
105
104
106
return $ this ;
@@ -111,6 +113,18 @@ public function dropIfExists(): self
111
113
} catch (\Doctrine \DBAL \Exception |\Doctrine \DBAL \DBALException $ e ) {
112
114
}
113
115
116
+ $ this ->createdTableNames = array_diff ($ this ->createdTableNames , [$ this ->table ->getName ()]);
117
+
118
+ // OracleSchemaManager::dropTable() called in self::drop() above tries to drop AI,
119
+ // but if AI trigger is not present, AI sequence is not dropped
120
+ if ($ this ->getDatabasePlatform () instanceof OraclePlatform) {
121
+ $ dropTriggerSql = $ this ->getDatabasePlatform ()->getDropAutoincrementSql ($ this ->table ->getName ())[1 ];
122
+ try {
123
+ $ this ->connection ->expr ($ dropTriggerSql )->execute ();
124
+ } catch (Exception $ e ) {
125
+ }
126
+ }
127
+
114
128
return $ this ;
115
129
}
116
130
@@ -152,6 +166,7 @@ public function id(string $name = 'id'): self
152
166
$ options = [
153
167
'type ' => 'integer ' ,
154
168
'ref_type ' => self ::REF_TYPE_PRIMARY ,
169
+ 'mandatory ' => true ,
155
170
];
156
171
157
172
$ this ->field ($ name , $ options );
0 commit comments