I'm working on a Symfony 2-application and I use Doctrine migrations to create the database. Now it is time to deploy my application to the production server, and I need some guidance on how to manage migrations. First, how can I get console access to my live server to run the migration command? If I can´t run migrations, can I import my local database to the new server, or will this break the application´s mapping structure, so it won´t work? I´m sorry if this seems like a silly question, but I really can´t find much information about this. I have searched for it a lot.
Several options:
A terminal connection to your deployment server to run the app/console there
Execute the migration in your local terminal, with env=prod, and with a parameters.yml file that points to your prod database
Export data from your local database, and import it in your remote one
Take care when doing these, and make proper backups to avoid data losses
Related
I will like to deploy an app that uses sqlite to Heroku. Googling for how to do this, I come across the official documentation of sqlite on hereku here
And the amazing thing is that, the documentation seems to be suggesting you should not use sqlite on heroku and then went further to tell you how to use Postgres instead!!!
Is it really impossible to use sqlite on heroku and have your data not transient?
Heroku has a database offering of its own, based on the Postgres database so it is necessary to switch so as to avoid the file-based SQlite. To connect to a Heroku database, you will need to use the Heroku CLI. That is the recommendation, as you have noted.
You can run heroku addons:add <your database choice, say the free tier one for example>. It is as simple as that.
If you try to run heroku config:get DATABASE_URL you will notice that a postgres://<> (now postgresql) has been created for you.
I am trying to deploy my flask app on Microsoft Azure. On the deployed site it can read the db fine, but whenever I try to write to the db, it gives: sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) database is locked
My file structure inside the app folder is:
templates
app.py
db.sqlite
However when i run it on my local, everything works fine. Any ideas how I can solve this?
Run from Package makes wwwroot read-only, and you will receive an error when writing files to this directory. You may refer to below links might be helpful:
https://github.com/Azure/app-service-announcements/issues/84
https://learn.microsoft.com/en-us/azure/azure-functions/run-functions-from-deployment-package
There is not more information for us to help fixing your issue, such as the necessary code and configuration for using SQLAlchemy with SQLite.
So I suggest that you can carefully refer to the some topics about SQLite locked file for writing.
Database Locking Behavior / Concurrency
The items Client/Server Applications and High Concurrency of the section Situations Where A Client/Server RDBMS May Work Better in the SQLite offical page Appropriate Uses For SQLite.
Meanwhile, some existing SO threads may will help you.
sqlite3.OperationalError: database is locked
SQLAlchemy and SQLite: database is locked
Hope it helps. If you can update your description to post more helpful information, I will try to reproduce your issue and fix it, and then update my post.
Is it possible lock the database from any other connections when running the migrations through Database.Migrate()?
We have multiple service instances running the same code (on AWS Lambda), and do the migrations on startup. Now we have to manually make sure that only one instance is running when we want to apply some migrations, otherwise they can both try to do it and break things bad.
Is there a database level solution to this?
ef-core 2.1
Not really sure if this is what you are looking for, but if you are willing to add plain SQL to your migration you could set database to single user mode: Read more
Hello I'm new to MVC and have been looking for a solution to my problem for the last couple days with no avail.
I've created a simple blog engine using ASP.NET MVC, after installing it on IIS on my local PC, I quickly realized I needed a database for the login service to work.
So I elected to use LocalDB on a PC that I plan to use as a server. I moved my files over to the PC and installed everything I needed. As soon as I installed SQLExpress with LocalDB and reset the site, everything was working perfectly. However, I noticed some minor typos on a section of the site that's not easily edited. Stupidly, I reinstalled the website entirely from a new build instead of just updating the view that needed correction like a smart person would do.
Now every time I attempt to login to an excising account or create a new one I simply get the error
Cannot attach the file 'C:\inetpub\wwwroot\App_Data\aspnet-FacetBlog-20161020065352.mdf' as database 'aspnet-FacetBlog-20161020065352'.
From what I've learned, It's something to do with my LocalDB instance, but fixes I've found online seem to have no effect.
Admittingly, I'm pretty naive with it comes to SQL, so hopefully the fix is simple. If I've failed to provide vital information please tell me and I'll update the question. Additionally, an explanation of what exactly went wrong would be much appreciated. Thank you for your time.
When reinstalling your site, probably you had deleted database file aspnet-FacetBlog-20161020065352.mdf in your database directory. Since deleting MDF file doesn't affect registered SQL Express instance, SQL Express thinks the database still exists and trying to connect but failed.
First, try to attach the DB using SSMS query like this:
EXEC sp_attach_db #dbname=N'aspnet-FacetBlog-20161020065352.mdf', #filename1=N'App_Data\aspnet-FacetBlog-20161020065352.mdf', #filename2=N'App_Data\aspnet-FacetBlog-20161020065352.ldf'
NB: I assumed your MDF file location stands in App_Data directory, change it to your actual database directory.
If attempt to attach by query doesn't work, try these steps:
Stop IIS/IIS Express pool if it still running.
Open a Windows Powershell instance on your server PC (install it first if doesn't exist).
Run the following command:
sqllocaldb.exe stop v11.0
sqllocaldb.exe delete v11.0
sqllocaldb.exe start v11.0
Recreate the DB instance on your project, including data connection in Server Explorer (remove then create).
Re-run the project in development machine, then copy all required files to server PC. The database instance should be (re-)generated at this time.
Restart IIS/IIS Express pool on server PC.
Additionally you may run Update-Database command from Package Manager Console to ensure database integrity.
If those solutions still won't work altogether, simply rename your database files and attach it on your project, verify the connection string then retry step (5) and (6) above.
Related problems:
EF5: Cannot attach the file ‘{0}' as database '{1}'
Cannot attach the file ".mdf" as database "aspnet-"
Delete .mdf file from app_data causes exception cannot attach the file as database
Cannot attach the file 'C:\inetpub\wwwroot\MvcApplication10\App_Data\aspnet-MvcApplication10-20130909002323.mdf' as database 'aspnet-MvcApplication10-20130909002323'
I'm using flask on appfog.com to make a personal blog. Today I tried to use sqlite. I can run the application locally with sqlite but when I update the app to AppFog, it does not seem to work. I can't find how to use sqlite in AppFog's docs. Can anyone tell me?
Thanks...
Sorry for my poor english:-)
It's not recommended to use sqlite for your production apps on AppFog because the file storage is ephemeral. Every time you update your app the database will get blown away. You're better off creating and binding a postgres, mysql, or mongodb database service for your app. You can continue to use sqlite db locally but your production app will use the bound service.
See the Bind Service section of: https://docs.appfog.com/languages/python/flask