the bot should work ...
The old version (version = '0.31.0') of the bot worked without problems!
After I executed: composer update there is no reaction even to command: /start at all.
New version of the telegram bot is: '0.49.0'.
There is no reaction at all to any commands!
scripts:
https://sample.dp.ua/telegram/unset.php
https://sample.dp.ua/telegram/set.php
executed without errors!
If execute script:
https://sample.dp.ua/telegram/hook.php
in browser, no errors too.
If i knew!
There are no logs, because the hook.php is not called.
The problem here is that you're updating from 0.31.0, which is a very old version.
There are a LOT of changes since then.
Please make sure that your DB structure is up-to-date. (check structure.sql in the root directory)
The encoding has been changed in all tables from:
DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
to:
DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
found differences in the structure.
There are a lot of differences in the structure of the tables!
There are such changes that some fields are deleted, and new ones are added. And this is a serious problem.
I could do export, then change the structure and make the import. But deleting fields, and adding new ones, will not allow me to make structure changes through export-import.
What do i do? maybe you have a set of scripts to change the structure of the database?
I can not lost data!
I was working on this for a while, but never got a 100% solution merged into the core repo.
Before you try anything, make a backup of your DB!
You can see my work here, which hopefully is enough for you to get this solved.
https://github.com/noplanman/php-telegram-bot/tree/db_schema_update/utils/db-schema-update/migration
Best if you manually go through each script and execute the commands. Some might fail due to the foreign key constraint indexes, so you'll need to update those manually. For the majority though, they should work fine.
As for the DB schema updates for 0.44.1+, look here: https://github.com/php-telegram-bot/core/tree/master/utils/db-schema-update
Thank you. I will try it!
Hi noplanman!
Help me please!
ALTER TABLE message
ADD CONSTRAINT message_ibfk_4 FOREIGN KEY (forward_from_chat) REFERENCES chat (id);
it does cause a mysql error:
ERROR 1005 (HY000): Can't create table 'telegram.#sql-8de_3e1e' (errno: 121)
Because message_ibfk_4 already exists! What do i do? give it another name? or remove this constrain? how it will be correct?
Additional Information about this problem:
select TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE where REFERENCED_TABLE_SCHEMA = 'telegram' AND REFERENCED_TABLE_NAME = 'message';
+-----------------+------------------+------------------------+-----------------------+------------------------+
| TABLE_NAME | COLUMN_NAME | CONSTRAINT_NAME | REFERENCED_TABLE_NAME | REFERENCED_COLUMN_NAME |
+-----------------+------------------+------------------------+-----------------------+------------------------+
| message | reply_to_chat | message_ibfk_4 | message | chat_id |
| message | reply_to_message | message_ibfk_4 | message | id |
| telegram_update | chat_id | telegram_update_ibfk_1 | message | chat_id |
| telegram_update | message_id | telegram_update_ibfk_1 | message | id |
+-----------------+------------------+------------------------+-----------------------+------------------------+
Sincerely, Alexander.
Easiest is to delete and recreate the constraints.
Or, if you're manually applying each script, just ignore certain parts of it.
Foreign keys are the main problem regarding an auto migration script.
I finished the migration with your scripts. in my logs there were first records. but the database structure is not yet up to the latest version of the bot. the bot is not working yet.
does not work the creating an object - ReplyKeyboardMarkup
What can be missing in the database structure?
ReplyKeyboardMarkup doesn't exist any more!
Use just Keyboard instead. Check this example to see how it works.
the command start - working! but there is a problem. we have 10 buttons!
The old version showed all the buttons, and the new one can show only one row of buttons.
there is an array with buttons:
$keyb = [
['๐ Currency rates','๐ Near you'],
['๐ณ Payments','๐ Services'],
['๐ News','โญ Promotions'],
['๐','๐ฑ','๐','โ']
];
// but I can show only one row of buttons:
$keyboards = ( new Keyboard( $keyb[ 0 ] ) )
->setResizeKeyboard( $resize_keyb )
->setOneTimeKeyboard( $one_time_keyb )
->setSelective( $selective );
$data['reply_markup'] = $keyboards;
How can I show the all elements array with buttons? $keyb[ 0 ], $keyb[ 1 ], $keyb[ 2 ] and $keyb[ 3 ] ?
excuse me, Keyboard works good.
I did this as follows:
$keybparam = [
'keyboard' => $keyb,
'resize_keyboard' => $resize_keyb,
'one_time_keyboard' => $one_time_keyb,
'selective' => $selective
];
if ( class_exists('Longman\TelegramBot\Entities\Keyboard' ) ) {
$data['reply_markup'] = new Keyboard( $keybparam );
} elseif ( class_exists('Longman\TelegramBot\Entities\ReplyKeyboardMarkup' ) ) {
$data['reply_markup'] = new ReplyKeyboardMarkup($keybparam );
}
thank you!