@@ -371,15 +371,6 @@ def create_tables(self) -> bool:
371371 return True
372372
373373 return False
374-
375- def create_schema (self ):
376- """~ Method ~
377- @Info: Creates the schema for the database (tables, views, funcions, procedures, triggers, etc.)"""
378- res = False
379- trace ("[SQL]: Creating schema..." , TraceLEVELS .NORMAL )
380- if self .create_tables ():
381- res = self .create_analytic_objects ()
382- return res
383374
384375 def connect_cursor (self ) -> bool :
385376 """ ~ Method ~
@@ -428,7 +419,7 @@ def initialize(self) -> bool:
428419 # return False
429420
430421 # Create tables and the session class bound to the engine
431- if not self .create_schema ():
422+ if not self .create_tables ():
432423 trace ("[SQL]: Unable to create all the tables." , TraceLEVELS .ERROR )
433424 return False
434425
@@ -533,8 +524,9 @@ def handle_error(self,
533524 res = False
534525 time .sleep (SQL_RECOVERY_TIME )
535526 # Handle the error
536- if exception == 208 : # Invalid object name (table deleted)
537- res = self .create_schema ()
527+ if exception == 208 : # Invalid object name (table deleted)
528+ if self .create_tables () and self .create_data_types () and self .create_analytic_objects ():
529+ res = True
538530 elif exception in {547 , 515 }: # Constraint conflict, NULL value
539531 r_table = re .search (r'(?<=table "dbo.).+(?=")' , message )
540532 if r_table is not None :
@@ -545,9 +537,8 @@ def handle_error(self,
545537 elif exception in {- 1 , 2 , 53 }: # Diconnect error, reconnect after period
546538 self .reconnect_after (SQL_RECONNECT_TIME , loop )
547539 elif exception == 2812 :
548- res = self .create_data_types () # Create data types
549- if res :
550- res = self .create_analytic_objects () # Creates procedures, functions and views
540+ if self .create_data_types () and self .create_analytic_objects ():
541+ res = True
551542 elif exception == 2801 : # Object was altered (via external source) after procedure was compiled
552543 res = True # Just retry
553544 elif exception == 1205 : # Transaction deadlocked
@@ -679,7 +670,7 @@ class GuildUSER(LoggerSQL.Base):
679670
680671 __tablename__ = "GuildUSER"
681672
682- id = Column (SmallInteger , Identity (start = 0 ,increment = 1 ),primary_key = True )
673+ id = Column (Integer , Identity (start = 0 ,increment = 1 ),primary_key = True )
683674 snowflake_id = Column (BigInteger )
684675 name = Column (NVARCHAR )
685676 guild_type = Column (SmallInteger , ForeignKey ("GuildTYPE.id" ), nullable = False )
@@ -702,10 +693,10 @@ class CHANNEL(LoggerSQL.Base):
702693 guild_id: int :: Snowflake identificator pointing to a GUILD/USER"""
703694
704695 __tablename__ = "CHANNEL"
705- id = Column (SmallInteger , Identity (start = 0 ,increment = 1 ),primary_key = True )
696+ id = Column (Integer , Identity (start = 0 ,increment = 1 ),primary_key = True )
706697 snowflake_id = Column (BigInteger )
707698 name = Column (NVARCHAR )
708- guild_id = Column (SmallInteger , ForeignKey ("GuildUSER.id" ), nullable = False )
699+ guild_id = Column (Integer , ForeignKey ("GuildUSER.id" ), nullable = False )
709700
710701 def __init__ (self ,
711702 snowflake : int ,
@@ -760,7 +751,7 @@ class MessageLOG(LoggerSQL.Base):
760751 id = Column (Integer , Identity (start = 0 , increment = 1 ), primary_key = True )
761752 sent_data = Column (Integer , ForeignKey ("DataHISTORY.id" ))
762753 message_type = Column (SmallInteger , ForeignKey ("MessageTYPE.id" ), nullable = False )
763- guild_id = Column (SmallInteger , ForeignKey ("GuildUSER.id" ), nullable = False )
754+ guild_id = Column (Integer , ForeignKey ("GuildUSER.id" ), nullable = False )
764755 message_mode = Column (SmallInteger , ForeignKey ("MessageMODE.id" )) # [TextMESSAGE, DirectMESSAGE]
765756 dm_reason = Column (NVARCHAR ) # [DirectMESSAGE]
766757 timestamp = Column (DateTime )
@@ -789,7 +780,7 @@ class MessageChannelLOG(LoggerSQL.Base):
789780 __tablename__ = "MessageChannelLOG"
790781
791782 log_id = Column (Integer , ForeignKey ("MessageLOG.id" , ondelete = "CASCADE" ), primary_key = True )
792- channel_id = Column (SmallInteger , ForeignKey ("CHANNEL.id" ), primary_key = True )
783+ channel_id = Column (Integer , ForeignKey ("CHANNEL.id" ), primary_key = True )
793784 reason = Column (NVARCHAR )
794785 def __init__ (self ,
795786 message_log_id : int ,
0 commit comments