Unable to auto-generate migrations using alembic - sqlalchemy

My repository can be found here http://goo.gl/Q4WJXy (versions inside alembic folder)and I tried to use autogenerate migrations,
alembic revision --autogenerate -m "some message"
there is nothing related to creation of table i.e empty downgrade and upgrade functions. I configured my local database properly. How can i solve this?
My log looks like this
INFO [alembic.migration] Context impl MySQLImpl.
INFO [alembic.migration] Will assume non-transactional DDL.
Target database is not up to date.
Thanks in advance

Basically Alembic compares your current database to your model and then generates the migration to get you database to be like your model.
I thought initially that the migrations is comparing latest revision with model, but actually it seems to ignore your revision file contents and is only looking to see if your database has the lates Alembic revision migration number.
So simply created the Alembic table and pasted the head revision number into it, in order for the migration to run and output the migration script I was looking for.
Alternatively you upgrade your database properly to the latest revision using Alembic and then create the new migration.
alembic upgrade head
alembic revision --autogenerate -m 'test revision'

Related

Git Pre-Commit Hook Adding File After Commit

I am attempting to dump a mysql database and add the .sql dump file to the staging area using a pre-commit hook so it can then be included in the commit (on Windows Server 2012 R2/IIS). The following code dumps the database nicely, but after I commit it still shows the be.sql file in the staging area...sometimes(?) - it seems to be adding the file to staging AFTER committing(?). This is a pre-commit hook so I have no idea why it may be adding the file after the commit takes place:
#!/bin/bash
# Dump Database
/c/Program\ Files\ \(x86\)/MySQL/MySQL\ Server\ 5\.7/bin/mysqldump.exe -u root --skip-extended-insert be > /c/inetpub/wwwroot/directory/be/be.sql
# Add Database
cd /c/inetpub/wwwroot/directory/be
git add be.sql
The behavior is a bit strange - I will see be.sql is still in the staging area so I will make a commit. If I git status afterwards the tree is clean. If I commit again and git status it will display the be.sql file in the staging index as modified (I didn't modify it). And back and forth it goes. I just want it to dump the .sql file, add the .sql file to the staging index, THEN commit so every time the staging index is clean. Any ideas as to why this is happening would be greatly appreciated.
Using:
git commit -m "Message" --allow-empty
when making the commit appears to have worked. It seems as if git needs other staged changes in order for the hook to work. So it was basically not making the commit, but still dumping the be.sql file, which would then show up in the staging index as modified the next time around because the date had changed. In order to allow the commit to fully go through regardless of whether or not there were other staged changes I used the --allow-empty option, which allows a commit with nothing in the staged index.

How do I get my Liquibase changeset to run if my SQL script changes?

I’m using LIquibase 3.3 and MySQL 5.5.37. I have this change set
<changeSet id="update-thirdparty-event-ids" author="davea" runOnChange="true">
<sqlFile path="scripts/my_table_thirdparty_event_ids.sql"
stripComments="true"/>
</changeSet>
I thought this changeset would run if I made changes to my SQL script. However, I’m noticing that even when I change my script, the changeset will not run if it has already run once before. What can I do to get the changeset to run if and only if my script changes?
Thanks, - Dave and
When you edit the file save it with a different name so that you have to change the changeset definition to point to the new file.
<sqlFile path="scripts/my_table_thirdparty_event_ids .rev3.sql"
stripComments="true"/>

Mercurial: Build script creates 2nd line when tagging the tip

I've hunted SO for other Mercurial posts relating to tags and build scripts but I didn't find the particular issue I'm seeing.
I've been using a bitbucket.org hosted Mercurial server for a few weeks. My workflow is to write code, push to the local repo then push to bitbucket. I'm the only contributor in my project and I only use one machine to code so I haven't had any tricky merges or conflicts to resolve yet. I use TortoiseHg to perform checkins and code reviews.
Today I wrote a script to automate my builds but I ran into a problem. I use c:\dev for coding and I use c:\build as the root folder for the build process.
My process is:
1) Get the latest code -- clone the repo or get latest if it is already cloned
2) Version the code
3) Build the code
4) Tag the local repo
5) Push the tag to bitbucket.org
I'm using a simple batch program:
REM variable assignment, versioning, and error checking are excluded from this snippet
ECHO Getting code from remote repository...
IF EXIST .\%localrepo% (
ECHO Pulling latest
hg pull %localrepo%
) else (
ECHO Cloning repository
hg clone %remoterepo%
)
ECHO Done retrieving code.
ECHO Building code...
"c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe" %solution% /build %solutionconfig%
ECHO Building complete.
cd %localrepo%
hg tag %version%
hg push
cd ..
This script seemed to achieve all of my goals and everything was going well until I went back to TortoiseHg and noticed that the revision Graph now shows two lines -- one for my c:\dev coding and another for the tag created by the build script in c:\build.
I don't have enough reputation to embed an image, but this link will show a screenshot of the revision history reported by TortoiseHg - http://i.imgur.com/2oNAR.png
With a bit of struggle, I merged the new line (revision 38) back to the original (revision 39), but when I ran the build script again (revision 40) the new tag continued on the 2nd line. I tried to commit a change from the dev repository, but that commit was aborted due to "push creates note remote head".
I feel like I'm maybe doing something fundamentally wrong in my build script. Any advice or topics I need to read up on? I failed to find any non-MSBuild scripting solutions relating to Mercurial code servers. I am not tied to using a batch script for any reason -- it was just a simple and free solution that I expected to be sufficient.
hg clone automatically updates your working directory to the tip of the default branch, but hg pull does not. Use hg pull -u to update the the head of your current branch after a pull.

HG Convert not working on local CVS repository

I have been trying to use HG convert to migrate a local CVS repository to HG. When I run the command...
hg convert CATools
I see the following message:
"Valid-requests", but got '')
"Valid-requests", but got '')> assuming destination CATools-hg
initializing destination CATools-hg
repository connecting to
:sspi:shcgl-egcrizan:2401:/cvsroot
Unknown command: `server'
CVS commands are:
add Add a new file/directory to the repository
admin Administration front end for rcs
annotate Show last revision where each line was modified
checkout Checkout sources for editing
commit Check files into the repository
diff Show differences between revisions
edit Get ready to edit a watched file
editors See who is editing a watched file
export Export sources from CVS, similar to checkout
history Show repository access history
import Import sources into CVS, using vendor branches
init Create a CVS repository if it doesn't exist
log Print out history information for files
login Prompt for password for authenticating server
logout Removes entry in .cvspass for remote repository
rannotate Show last revision where each line of module was
modified
rdiff Create 'patch' format diffs between releases
release Indicate that a Module is no longer in use
remove Remove an entry from the repository
rlog Print out history information for a module
rtag Add a symbolic tag to a module
status Display status information on checked out files
tag Add a symbolic tag to checked out version of files
unedit Undo an edit command
update Bring work tree in sync with repository
version Show current CVS version(s)
watch Set watches
watchers See who is watching a file (Specify the --help
option for a list of other help
options) abort: unexpected response
from CVS server (expected
"Valid-requests", but got '')"Valid-requests", but got '')
Has anybody found a workaround? I found this article but do not understand how to do this on Windows.
http://blog.edsantiago.com/archives/2009/02/19/#e2009-02-19T19_23_32.txt
Please consider using cvs2hg for the conversion. "hg convert" is known to have problems with nontrivial CVS repositories, for example often silently producing a Mercurial repository whose branch/tag contents do not agree with those in the CVS repository. Unless you require incremental conversion (and can live with inaccuracies), "hg convert" is not a reliable solution for converting from CVS to Mercurial.
How "local" is local? If you have filesystem access to the CVS repository, you can just copy it over and do a real local hg convert.

Build a specific revision in Hudson?

How do I ask Hudson to build a specific revision (instead of the latest one)? I am using Mercurial in case that's relevant.
Under the Hudson project's Mercurial configuration, you can try putting the revision you'd like to build into the Branch field. (And if that doesn't work create a branch based on that revision.)
More generally, if you want the ability to build a revision that you specify at build time, you can configure a parameterized build that uses the user-specified revision parameter in the Branch field. The Mercurial Plugin claims to support parameters in the Branch field (as of version 1.26).
[Disclaimer: I don't have the setup to try this myself. So it's an educated guess.]
I am not sure if this will help in your case(Hudson), Normally if we want to build a specific revision we update to that revision build it. You can update to a revision by:
hg update -r <revision>
That update the repo to given revision and you can run your build commands
or if you don't want to do build inside the repo you can archive it and build out side the repo
hg archive -r <revision>
hg help archive