Create users table if missing
This commit is contained in:
parent
06d3569fbd
commit
87d95fbfed
@ -14,7 +14,7 @@ __author__ = "Davide Testa"
|
|||||||
__email__ = "davide@davte.it"
|
__email__ = "davide@davte.it"
|
||||||
__credits__ = ["Marco Origlia", "Nick Lee @Nickoala"]
|
__credits__ = ["Marco Origlia", "Nick Lee @Nickoala"]
|
||||||
__license__ = "GNU General Public License v3.0"
|
__license__ = "GNU General Public License v3.0"
|
||||||
__version__ = "2.4.15"
|
__version__ = "2.4.16"
|
||||||
__maintainer__ = "Davide Testa"
|
__maintainer__ = "Davide Testa"
|
||||||
__contact__ = "t.me/davte"
|
__contact__ = "t.me/davte"
|
||||||
|
|
||||||
|
@ -223,17 +223,37 @@ class Bot(TelegramBot, ObjectWithDatabase, MultiLanguageObject):
|
|||||||
self.shared_data = dict()
|
self.shared_data = dict()
|
||||||
self.Role = None
|
self.Role = None
|
||||||
# Add `users` table with its fields if missing
|
# Add `users` table with its fields if missing
|
||||||
self.db['users'].upsert(
|
if 'users' not in self.db.tables:
|
||||||
dict(
|
table = self.db.create_table(
|
||||||
telegram_id=000000000,
|
table_name='users'
|
||||||
privileges=100,
|
)
|
||||||
username="username",
|
table.create_column(
|
||||||
first_name="First",
|
'telegram_id',
|
||||||
last_name="Last",
|
self.db.types.integer
|
||||||
language_code="en",
|
)
|
||||||
selected_language_code="en"
|
table.create_column(
|
||||||
),
|
'privileges',
|
||||||
['telegram_id']
|
self.db.types.integer
|
||||||
|
)
|
||||||
|
table.create_column(
|
||||||
|
'username',
|
||||||
|
self.db.types.string
|
||||||
|
)
|
||||||
|
table.create_column(
|
||||||
|
'first_name',
|
||||||
|
self.db.types.string
|
||||||
|
)
|
||||||
|
table.create_column(
|
||||||
|
'last_name',
|
||||||
|
self.db.types.string
|
||||||
|
)
|
||||||
|
table.create_column(
|
||||||
|
'language_code',
|
||||||
|
self.db.types.string
|
||||||
|
)
|
||||||
|
table.create_column(
|
||||||
|
'selected_language_code',
|
||||||
|
self.db.types.string
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user