Updated for clean data

This commit is contained in:
Dimitris Zlatanidis 2023-03-06 21:04:44 +02:00
parent 6ab626cab2
commit 36a6f444c4
3 changed files with 16 additions and 11 deletions

View file

@ -47,8 +47,8 @@ Deletes all the downloaded SlackBuilds scripts and sources.
.P .P
.B -T, clean-data .B -T, clean-data
.RS .RS
Sometimes is necessary to clean all the data from the database. Sometimes is necessary to clean all the repositories data from the database.
Run this command to drop all the tables from the database and run '\fIslpkg update\fR' to recreate. Run this command to delete all the data and run '\fIslpkg update\fR' to recreate.
.RE .RE
.P .P
.B -g, configs .B -g, configs

View file

@ -27,18 +27,18 @@ class UpdateRepository(Configs, Utilities):
self.flags: list = flags self.flags: list = flags
self.session = Session self.session = Session
self.view = ViewMessage(self.flags)
self.progress = ProgressBar() self.progress = ProgressBar()
self.color = self.colour() self.color = self.colour()
self.endc: str = self.color['endc'] self.endc: str = self.color['endc']
self.flag_generate: list = ['-G', '--generate-only'] self.flag_generate: list = ['-G', '--generate-only']
self.flag_drop_all: list = ['-A', '--drop-all']
def sbo(self) -> None: def sbo(self) -> None:
""" Updated the sbo repository. """ """ Updated the sbo repository. """
view = ViewMessage(self.flags) self.view.question()
view.question()
if self.ponce_repo: if self.ponce_repo:
@ -125,9 +125,14 @@ class UpdateRepository(Configs, Utilities):
self.session.query(SBoTable).delete() self.session.query(SBoTable).delete()
self.session.commit() self.session.commit()
@staticmethod def drop_the_tables(self):
def drop_the_tables():
""" Drop all the tables from the database. """ """ Drop all the tables from the database. """
Base.metadata.drop_all(bind=engine, tables=[PonceTable.__table__, print('All the data from the database will be deleted.')
SBoTable.__table__, self.view.question()
LogsDependencies.__table__])
tables: list = [PonceTable.__table__,
SBoTable.__table__]
Base.metadata.drop_all(bind=engine, tables=tables)
print("Successfully cleared!\n\nYou need to run 'slpkg update' now.")

View file

@ -48,7 +48,7 @@ class Usage(Configs):
f' {self.cyan}-g, configs{self.endc} Edit the configuration file.\n' f' {self.cyan}-g, configs{self.endc} Edit the configuration file.\n'
f' {self.cyan}-L, clean-logs{self.endc} Clean dependencies log tracking.\n' f' {self.cyan}-L, clean-logs{self.endc} Clean dependencies log tracking.\n'
f' {self.cyan}-D, clean-tmp{self.endc} Delete all the downloaded sources.\n' f' {self.cyan}-D, clean-tmp{self.endc} Delete all the downloaded sources.\n'
f' {self.cyan}-T, clean-data{self.endc} Clean all the data from the database.\n' f' {self.cyan}-T, clean-data{self.endc} Clean all the repositories data.\n'
f' {self.cyan}-b, build{self.endc} [packages...] Build only the packages.\n' f' {self.cyan}-b, build{self.endc} [packages...] Build only the packages.\n'
f' {self.cyan}-i, install{self.endc} [packages...] Build and install the packages.\n' f' {self.cyan}-i, install{self.endc} [packages...] Build and install the packages.\n'
f' {self.cyan}-d, download{self.endc} [packages...] Download only the scripts and sources.\n' f' {self.cyan}-d, download{self.endc} [packages...] Download only the scripts and sources.\n'