Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Firdavs Khaydarov Posted March 18, 2018 Posted March 18, 2018 I'm trying to run this code on plugin install, but get an error: Code: \IPS\Db::i()->createTable([ 'name' => 'sypexgeo_cache', 'columns' => [ \IPS\Db::i()->compileColumnDefinition([ 'name' => 'ip_address', 'type' => 'VARCHAR', 'length' => 46, 'allow_null' => false, 'comment' => 'The IP address' ]), \IPS\Db::i()->compileColumnDefinition([ 'name' => 'data', 'type' => 'TEXT', 'allow_null' => true, 'comment' => 'The JSON-encoded data returned by the service' ]), \IPS\Db::i()->compileColumnDefinition([ 'name' => 'date', 'type' => 'INT', 'length' => 10, 'allow_null' => false, 'comment' => 'Unix timestamp of when the data was retrieved' ]) ], 'indexes' => [ \IPS\Db::i()->compileIndexDefinition([ 'type' => 'primary', 'name' => 'PRIMARY', 'columns' => [ 'ip_address' ], 'length' => [ null ] ]), \IPS\Db::i()->compileIndexDefinition([ 'type' => 'key', 'name' => 'date', 'columns' => [ 'date' ], 'length' => [ null ] ]) ], 'comment' => 'Sypexgeo cache table' ]); It's a copy of IPS's core_geoip_cache table.
newbie LAC Posted March 18, 2018 Posted March 18, 2018 \IPS\Db::i()->createTable([ 'name' => 'sypexgeo_cache', 'columns' => [ 'ip_address' => [ 'name' => 'ip_address', 'type' => 'VARCHAR', 'length' => 46, 'allow_null' => false, 'comment' => 'The IP address' ], 'data' => [ 'name' => 'data', 'type' => 'TEXT', 'allow_null' => true, 'comment' => 'The JSON-encoded data returned by the service' ], 'date' => [ 'name' => 'date', 'type' => 'INT', 'length' => 10, 'allow_null' => false, 'comment' => 'Unix timestamp of when the data was retrieved' ] ], 'indexes' => [ 'PRIMARY' => [ 'type' => 'primary', 'name' => 'PRIMARY', 'columns' => [ 'ip_address' ], 'length' => [ null ] ], 'date' => [ 'type' => 'key', 'name' => 'date', 'columns' => [ 'date' ], 'length' => [ null ] ] ], 'comment' => 'Sypexgeo cache table' ]); Don't forget try/catch
newbie LAC Posted March 31, 2018 Posted March 31, 2018 BTW if you want to create a copy of any table structure use \IPS\Db::i()->duplicateTableStructure('exists_table_name', 'new_table_name'); In your case \IPS\Db::i()->duplicateTableStructure('core_geoip_cache', 'sypexgeo_cache');
Recommended Posts
Archived
This topic is now archived and is closed to further replies.