使用“git aws.push”覆盖我的弹性beanstalk应用程序所拥有的数据库

时间:2022-08-25 09:23:25

I have a "comments.db" file in the root of my git repo for a flask application hosted by amazon.

我在我的git repo的根目录中有一个“comments.db”文件,用于由amazon托管的烧瓶应用程序。

It works just fine on the server - when someone adds a comment to a post, the database on the server gets updated accordingly. However, any time I make a change to some other part of the application any use "git aws.push" to push those changes to the server, the database on the server gets overwritten with the database file on my local machine - so any entries that were added to server database are lost.

它在服务器上工作得很好 - 当有人在帖子中添加注释时,服务器上的数据库会相应地更新。但是,每当我对应用程序的其他部分进行更改时,任何使用“git aws.push”将这些更改推送到服务器,服务器上的数据库都会被本地计算机上的数据库文件覆盖 - 所以任何条目添加到服务器数据库的内容将丢失。

It also seems that if I stick "comments.db" in my gitignore, then "git aws.push" removes the database file from the server entirely.

似乎如果我在我的gitignore中粘贴“comments.db”,那么“git aws.push”将完全从服务器中删除数据库文件。

How can I make unrelated changes to my application and push them without clobbering the database on the server?

如何对我的应用程序进行无关的更改并推送它们而不破坏服务器上的数据库?

2 个解决方案

#1


1  

As you have discovered, Elastic Beanstalk does not keep old files when you update your application. Only files for the application itself should be in the app. You should store your data in one of Amazon's other database services, like RDS, and user uploaded files in S3.

正如您所发现的,当您更新应用程序时,Elastic Beanstalk不会保留旧文件。只有应用程序本身的文件应该在应用程序中。您应该将数据存储在Amazon的其他数据库服务(如RDS)和用户上载的S3中。

#2


0  

Has comments.db ever been checked in? I think it would work better if the file where free of the repository, it git would never see it or touch it.

有没有注册过的评论。我认为如果文件中没有存储库,git将永远不会看到它或触摸它会更好。

If it's already a part of the repository you can remove it with git rm --cached. This will leave it in the working copy where you run the command but delete it every where else when they do git pull so do it on the production machine to leave the file.

如果它已经是存储库的一部分,您可以使用git rm --cached将其删除。这将把它留在你运行命令的工作副本中,但是当它们执行git pull时将其删除,所以在生产机器上执行它以离开文件。

On each development machine you can create a new identical file used for development and test.

在每台开发机器上,您可以创建用于开发和测试的新相同文件。

Don't forget to add it to your ignore/exclude files.

不要忘记将其添加到您的忽略/排除文件中。

#1


1  

As you have discovered, Elastic Beanstalk does not keep old files when you update your application. Only files for the application itself should be in the app. You should store your data in one of Amazon's other database services, like RDS, and user uploaded files in S3.

正如您所发现的,当您更新应用程序时,Elastic Beanstalk不会保留旧文件。只有应用程序本身的文件应该在应用程序中。您应该将数据存储在Amazon的其他数据库服务(如RDS)和用户上载的S3中。

#2


0  

Has comments.db ever been checked in? I think it would work better if the file where free of the repository, it git would never see it or touch it.

有没有注册过的评论。我认为如果文件中没有存储库,git将永远不会看到它或触摸它会更好。

If it's already a part of the repository you can remove it with git rm --cached. This will leave it in the working copy where you run the command but delete it every where else when they do git pull so do it on the production machine to leave the file.

如果它已经是存储库的一部分,您可以使用git rm --cached将其删除。这将把它留在你运行命令的工作副本中,但是当它们执行git pull时将其删除,所以在生产机器上执行它以离开文件。

On each development machine you can create a new identical file used for development and test.

在每台开发机器上,您可以创建用于开发和测试的新相同文件。

Don't forget to add it to your ignore/exclude files.

不要忘记将其添加到您的忽略/排除文件中。