I have a CRUD app that will be used to track trucking appointments. I'm ready to deploy the app, but I'm worried about merging a future branch into the main branch without overwriting the existing information in the database. How can I use CLI git commands to avoid overwriting the data?
These are the general steps I've been using to merge a branch that I've made edits to into the main branch:
>git checkout main
>git merge <branch_name>
>git branch -d <branch_name>
>git push origin --delete <branch_name>
CodePudding user response:
I moved my test.db
file to a .gitignore
folder within my project. This way, any changes I make to the code in the future will not impact the appointments within the db.
I had to make this small change in my code to account for the new .gitignore
folder:
app = Flask (__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///.gitignore/test.db'
db = SQLAlchemy(app)
CodePudding user response:
Production data should not be stored in the same directory as code for many reasons other than worrying that git will overwrite your data. For one, your software shouldn't have permissions to modify itself, even though it needs permissions to overwrite its database. You'll need to search/ask how best to package Python and set up a service on the operating system you'll be using.
git has some safety features that protect untracked files. checkout
and switch
won't clobber them. But clean
is designed to delete untracked files. Worse: reset --hard
will overwrite untracked files without warning. Do not put important data in a working directory unless it's part of the project.