Rework blog section
Wrok in bloc sectionn
This commit is contained in:
@@ -32,36 +32,25 @@ def init_db(database):
|
||||
Mail_rescue TEXT )
|
||||
""")
|
||||
conn.commit()
|
||||
print ('table users Ok')
|
||||
|
||||
cursor.execute("""
|
||||
CREATE TABLE IF NOT EXISTS posts(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
|
||||
title TEXT,
|
||||
content TEXT,
|
||||
time TEXT,
|
||||
category TEXT,
|
||||
author TEXT,
|
||||
status TEXT
|
||||
)
|
||||
""")
|
||||
print ("table users Ok")
|
||||
|
||||
cursor.execute("""
|
||||
CREATE TABLE IF NOT EXISTS Blog_posts(
|
||||
title TEXT NOT NULL,
|
||||
subtitle TEXT,
|
||||
comments TEXT,
|
||||
filename TEXT,
|
||||
time TEXT,
|
||||
content TEXT,
|
||||
creation_date TEXT,
|
||||
last_updated TEXT,
|
||||
category TEXT,
|
||||
author TEXT,
|
||||
status TEXT,
|
||||
blog_theme TEXT,
|
||||
PRIMARY KEY(title, author)
|
||||
)
|
||||
""")
|
||||
conn.commit()
|
||||
|
||||
print ("Table Blog_posts Ok !")
|
||||
|
||||
cursor.execute("""select * from users""")
|
||||
accounts = cursor.fetchall()
|
||||
@@ -91,10 +80,12 @@ def db_migrate(database):
|
||||
cursor.execute("""SELECT name FROM PRAGMA_TABLE_INFO('users');""")
|
||||
db_columns = cursor.fetchall()
|
||||
invitations_col = False
|
||||
blog_theme_col = False
|
||||
updated_col = False
|
||||
lost_password_token_col = False
|
||||
totp_col = False
|
||||
blog_theme_col = False
|
||||
updated_col = False
|
||||
creation_date_col = False
|
||||
content_col = False
|
||||
|
||||
for col in db_columns:
|
||||
if "invitations" == col[0]:
|
||||
@@ -111,7 +102,12 @@ def db_migrate(database):
|
||||
blog_theme_col = True
|
||||
if "last_updated" == col[0]:
|
||||
updated_col = True
|
||||
|
||||
if "content" == col[0]:
|
||||
content_col = True
|
||||
if "creation_date" == col[0]:
|
||||
creation_date_col= True
|
||||
if "category" == col[0]:
|
||||
category_col= True
|
||||
|
||||
|
||||
if not(invitations_col):
|
||||
@@ -143,5 +139,20 @@ def db_migrate(database):
|
||||
print ("Ajout du champ updated dans la table BLog")
|
||||
|
||||
|
||||
if not(content_col):
|
||||
cursor.execute("""ALTER TABLE Blog_posts RENAME COLUMN filename TO content;""")
|
||||
conn.commit()
|
||||
print ("Filename renomé en content")
|
||||
|
||||
|
||||
if not(creation_date_col):
|
||||
cursor.execute("""ALTER TABLE Blog_posts RENAME COLUMN time TO creation_date;""")
|
||||
conn.commit()
|
||||
print ("Time renomé en creation_date")
|
||||
|
||||
if not(category_col):
|
||||
cursor.execute("""ALTER TABLE Blog_posts ADD COLUMN category TEXT;""")
|
||||
conn.commit()
|
||||
print ("Ajout de la colono category")
|
||||
|
||||
conn.close()
|
||||
|
||||
Reference in New Issue
Block a user