hasTable($table)){ $expected=['id','tenant_id','company_id','unit_id','name','version','data','created_at','updated_at']; if(in_array($table,['a_service_drafts','a_billing_drafts'],true))$expected=[...$expected,'client_id','state']; if($table==='a_billing_drafts')$expected[]='source_id'; $columns=$this->getColumns($table);$names=array_column($columns,'name');sort($expected);sort($names); if($names!==$expected)throw new \LogicException('COMPOSITION_EXISTING_TABLE_INCOMPATIBLE: '.$table); foreach($columns as $column){ $type=$column['type_name'];$name=$column['name']; $valid=match($name){'data'=>$type==='jsonb','name','state'=>$type==='varchar','created_at','updated_at'=>$type==='timestamptz','version'=>in_array($type,['int4','integer'],true),default=>in_array($type,['int8','bigint'],true)}; if(!$valid)throw new \LogicException('COMPOSITION_EXISTING_COLUMN_INCOMPATIBLE: '.$table.'.'.$name); } $this->reused[]=$table; return; } parent::create($table,$callback); } }