
    Vj                     P    d Z ddlmZ ddlmZmZ ddlmZ d Ze	dk(  r e        yy)zApply the explicit MySQL schema for the Venda Local module.

Run once from the project root:
    .\.venv\Scripts\python.exe app/scripts/apply_local_sales_schema.py
    )Path)inspecttext)enginec                  z   t        t              j                  dz  dz  } | j                  d      }g }g }|j	                         D ]3  }|j                         j                  d      r#|j                  |       5 dj                  |      j                  d      D ]&  }|j                         }|s|j                  |       ( t        j                         5 }|D ]  }|j                  t        |              t        |      }d|j                         v rs|j!                  d      D ch c]  }|d	   	 }	}d
|	vr4|j                  t        d             |j                  t        d             |j                  t        d             d d d        t#        dt%        |       d       y c c}w # 1 sw Y   'xY w)Nsqlzlocal_sales_tables.sqlzutf-8)encodingz--
;salesnamechannel_keyzUALTER TABLE sales ADD COLUMN channel_key VARCHAR(50) NOT NULL DEFAULT 'mercado_livre'z9CREATE INDEX idx_sales_channel_key ON sales (channel_key)z\UPDATE sales SET channel_key = 'mercado_livre' WHERE channel_key IS NULL OR channel_key = ''zVenda Local: u$    instruções aplicadas com sucesso.)r   __file__parent	read_text
splitlinesstrip
startswithappendjoinsplitr   beginexecuter   r   get_table_namesget_columnsprintlen)
schema_pathcontents
statementscurrentline	statement
connection	inspectorcolumncolumnss
             R/var/www/hypershopcomercio.com.br/hyper-ai/app/scripts/apply_local_sales_schema.pymainr)      s   x.''%/2JJK$$g$6HJG##% ::<""4(t YYw'--c2 )	OO%	i()
 
 :# 	0ItI/	0
 J'	i//114=4I4I'4RS&vf~SGSG+""4k$  ""4(c#detn  " 
M#j/**N
OP T s    AF1+F,7AF1,F11F:__main__N)
__doc__pathlibr   
sqlalchemyr   r   app.core.databaser   r)   __name__     r(   <module>r2      s0     $ $QD zF r1   