I am trying to do a rollback with South in my django app. I am getting this message when I run my command: DatabaseError: table "forms_logo_version" does not exist. This is the command I'm running python manage.py migrate myformsapp 0044.
I've checked the DB and the table does not exist, but why is this a problem? If I am deleting the table anyway, why is this throwing an error? Is there anyway I force the script to continue?
I have simply created a blank table in the database and the script ran fine after that. I would still like to know the answer to my questions above.
You can find in your migrations file 0044_*.py method named backwards and remove line with something similar to db.delete_table('forms_logo_version'). If you do this makes some tests.
Connect to empty db and make forward migration and backwards, to be sure your changes don't affect another migration file.
I recommend you to figure it out why this table is missing from db? Probably South create this table (look into migrations) and only South should remove it.
Related
I have made use of a backup database and have added a new table using Code First. Now when I tried using add-migration, I got this error:
Unable to generate an explicit migration because the following
explicit migrations are pending
Suggesting that the Migrations in the project do not match which are in the DB, which when I looked, there are NO migrations in the __migration table any more ?
As these tables exist in the DB, how do I get all of these migrations inserted into my SQL DB ? Is there a way I can get them all added, so that the projects migrations and the SQL DB migrations will match, so that I can continue adding/editing tables ?
Thanks in advance for any help.
So I found something that did help! It unfortunately meant that I lost all of my migration files, but thats not the end of the world.
The below is reference from this site: Click here
Remove the _MigrationHistory table from the Database
Remove the individual migration files in your project's Migrations folder
Enable-Migrations in Package Manager Console
Add-migration Initial in PMC
Comment out the code inside of the Up method in the Initial Migration
Update-database in PMC (does nothing but creates Migration Entry)
Remove comments in the Initial method
I hope this helps someone else as well.
I'm using Visual Studio 15.8.5 with Sql Server Data Tools 15.1.
I've created an SQL Server database project and imported the schema of an already existing database. I've made several minor changes to a few tables of the database and published the updates to the development database without any problems.
After adding a few SQL scripts to the project, all of them with:
Build Action = None
publish fails, despite no changes have been made in any of the database objects of the project.
This is the part of the auto-generated publish script that causes the problem:
/*
The table [lut].[KAE] is being dropped and re-created since all
non-computed columns within the table have been redefined.
*/
IF EXISTS (select top 1 1 from [lut].[KAE])
RAISERROR (N'Rows were detected. The schema update is terminating
because data loss might occur.', 16, 127) WITH NOWAIT
GO
Table [lut].[KAE] has not been changed, though. One of the scripts is redefining its schema but this should make no difference since this is a 'No Build' script.
What am I possibly doing wrong here?
Edit:
I've done a schema comparison as #MadBert advised. I originally used my actual database as source and my sql server visual studio project as target. No differences were found.
I then switched source and target databases and compared again. The following 'difference' was detected.
As you can see this is not an actual difference, it looks like a Visual Studio bug in schema comparison. Any ideas on how I could circumvent this behavior?
It turned out that a refactor log file was the culprit.
I tried to publish to an empty database, as #Ogglas wisely advised. I noticed that during publish I was getting the following message:
The following operation was generated from a refactoring log file
8e659d92-10bb-4ce9-xxxx-xxxxxxxxx Rename [lut].[KAE].[xxxxx] to
$$$$$$$$$ Caution: Changing any part of an object name could
break scripts and stored procedures.
I then noticed that my SQL Server Database project contained a .refactorlog file
It seems that this log file was generated after I changed the offending table schema. The schema of the table was later reverted to its original state but the log file remained.
I deleted this log file and after that publish finally succeeded!
Had a similar problem when a SQL Server Database project was set to the wrong Target platform. Edit this in project properties to match the target server. Initiate a schema compare again by right clicking on the project and select Schema Compare....
Also check if Ignore whitespace is marked in Schema Compare Options. If you still have a difference one way or another try pasting the text in Notepad++ with Show All Characters on and see if you can spot a difference.
If you still can't find any difference, try creating a new database from the project and use SSMS GUI to compare. Does the table have the same Lock Escalation settings etc?
I have created database project in visual studio 2013. Project build successfully . In this project I have inserted some test data in post deployment. If any data failed to insert then how can know the one of script is failed at particular location.
Actually I want to rollback all the thing if any command is failed from script file itself. Since SQL Server 2012 is not supporting rollback from pre/post deployment script.
The result window will give you the line and details of any error, it is a bit annoying as it will sometimes show the text of the beginning of the script but the error line number will be correct.
General things you should do is to make sure your insert scripts are re-runnable and then if you really can't see the error you can run the script yourself to debug it.
I would really recommend using MERGE statements to do the inserts :)
I also generally recommend using sqlpackage.exe to push to local Deb instances rather than the vs publish, see:
https://the.agilesql.club/blog/Ed-Elliott/Visual-Studio-SSDT-Publish-My-Personal-Best-Practices
Ed
After I uploaded my application created using cakephp, I found out that I had to rename the database. I renamed my database accordingly and changed the settings in the database.php file in the "config" folder. But my application is still not running.
I am being shown this error message
"Missing Database table"
"Error: Database table tbl_topics for model Topic was not found."
I have double checked the existence of tbl_topics in the database (it is there in the database) but the application says "table not found"
what might be the problem, please help me out...
Make sure the host/user/pass that you've set-up in the config.php file have access to that database and table
You could also try running cake schema generate --dry which will spit back any problems with the connection that you might be having
Also have a look in your app/tmp/logs for some extra information on the problems you are experiencing
Take the username and password you are using for cakephp and it's db connection and connect to the database from the command line. I'm presuming you are using a unix-type system and mysql?
mysql --user=user_name --password=your_password db_name
...and then try to run a simple select:
SELECT * FROM tbl_topics
If you get an error there, it will at least identify that it is a low level db problem and the likely solution is that you need to grant permissions to that username to select from that database. Your current access levels for that user is probably granting access to the db under the old name.
You have probably uploaded your cache files as well. Make sure you delete all the files in /app/tmp/cache/*
Warning: Don't delete the folders, files only!
Also, make sure your tmp folder and all the subfolders are world-writable.
One last thought would be to check your model cache. I don't know why that would impact you with respect to connecting, but it's worth taking a look in app/tmp/cache.
:-)
finally got it.... :-D
I forgot to assign the user access to my application's database on main server. After assigning the permissions all went fine.
Anyways thank you all for your valuable answers... It helped me gain some additional knowledge about cakephp.
Hey All, I have been working on this problem for a while and the usual google searches are not helping :(
I have a production database in SQL 2000. I want to copy it over the top of a training database to refresh it. I want this to be something that is scheduled to happen once a week to keep the training database up-to-date.
I have a DTS job created for doing this. Within that DTS job I have a single "Copy SQL Server Objects" task. That task is set up to:
Create all copied objects
Drop destination objects first
Copy data
Replace existing data
Copy indexes, triggers, primary and foreign keys
Copy all user tables, views, functions and stored procedures.
When I run this DTS package (in pre-production for testing of course) it gets to 99% done and throws the following error:
Step Error Source: Microsoft SQL-DMO (ODBC SQLState: 42S02)
Step Error Description:[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'dbo.vwEstAssetStationAddress'.
Step Error code: 800400D0
Step Error Help File:SQLDMO80.hlp
Step Error Help Context ID:1131
My searches on the net didn't provide much help. There are reports of these errors getting hit, but none seem to match my circumstances. One suggestion I found was the the sysdepends table had become corrupted, making the DTS job run its scripts in the wrong order. Howeever, I ran the following script to correct that table and it still throws the same error:
USE master
GO
ALTER DATABASE [DATABASE NAME]
SET SINGLE_USER
GO
USE [DATABASE NAME]
GO
DBCC CHECKTABLE('sysdepends',REPAIR_REBUILD )
GO
USE master
GO
ALTER DATABASE [DATABASE NAME]
SET MULTI_USER
GO
I have also seen that having different object owners can cause this error. But I have confirmed that the objects are all owned by the dbo user in this case.
Any suggestions?
I feel stupid, but am posting the answer I just found for posterity (and so all you helpful fellows can stop stressing on my behalf.
Even though I had selected all the user tables, views, stored procedures and user defined functions to copy, I hadn't selected "Include all dependant objects". I had assumed that if you selected two objects to copy, and one was dependant on the other, SQL would always do them in the correct order. Aparrently not. Selecting this little check box made all the difference.
Thanks again to those who helped with suggestions
Somehow the dbo.vwEstAssetStationAddress table is not being found by your DTS package. Unfortunately, the message doesn't say if it was on the source or destination that it couldn't find it.
What are the exact steps, in the order that you have them in your DTS package? I'm assuming that the list of the task items above is not in order. I know this not an answer, but it looks like we are going to need a bit more information to help you further.
Thanks for the response hectorsosajr.
the object aparrently causing the error (dbo.vwEstAssetStationAddress) is a view that references 2 underlying tables. I have tested querying the view, as well as running the SELECT statement that defines it, on both the source and destination databases and it works fine.
The database object copy task in DTS doesn't allow you to specify the order it transfers things in. As far as I understand it, it uses the sysdepends table to determine the requisite order of events.
I was trying to avoid doing it via backup / restore. There are some users of the database that are SQL Server accounts (not Active Directory). This becomes a pain in the but if you need to do it from one server to another as you have to drop those users and recreate them.
Sounds like it is trying to create a stored procedure/view based on a view that doesn't yet exist.
Why not just backup and restore the database under a different name? (if it wasn't production, I would say detach, copy and re-attach). You can do all that under the control of T-SQL.
See if this link helps you find your dependency issue.
I've run another test to try and isolate this. I removed the mentioned view from the destination database totally, then ran the DTS again. It failed with the same error. However, the view that aparrently is an invalid object name was recreated successfully. It seems that the error is coming from something trying to reference that view, but it doesn't actually stop the script when it hits that error.
Cade - I will check out that link. I will also try and establish what is referencing the view and breaking.