Dependency graph of Visual Studio projects

I needed something similar, but didn’t want to pay for (or install) a tool to do it. I created a quick PowerShell script that goes through the project references and spits them out in a yuml.me friendly-format instead: Function Get-ProjectReferences ($rootFolder) { $projectFiles = Get-ChildItem $rootFolder -Filter *.csproj -Recurse $ns = @{ defaultNamespace = “http://schemas.microsoft.com/developer/msbuild/2003” … Read more

How do you write a migration to rename an ActiveRecord model and its table in Rails?

Here’s an example: class RenameOldTableToNewTable < ActiveRecord::Migration def self.up rename_table :old_table_name, :new_table_name end def self.down rename_table :new_table_name, :old_table_name end end I had to go and rename the model declaration file manually. Edit: In Rails 3.1 & 4, ActiveRecord::Migration::CommandRecorder knows how to reverse rename_table migrations, so you can do this: class RenameOldTableToNewTable < ActiveRecord::Migration def change … Read more

Rails migration for change column

Use #change_column. change_column(:table_name, :column_name, :date) # a few more examples: change_column(:suppliers, :name, :string, limit: 80) change_column(:accounts, :description, :text) NOTE: the same result can be achieved even outside of db migrations, this might be handy for testing/debugging but this method needs to be used very cautiously: ActiveRecord::Base.connection.change_column(:table_name, :column_name, :date)

Loading initial data with Django 1.7 and data migrations

Update: See @GwynBleidD’s comment below for the problems this solution can cause, and see @Rockallite’s answer below for an approach that’s more durable to future model changes. Assuming you have a fixture file in <yourapp>/fixtures/initial_data.json Create your empty migration: In Django 1.7: python manage.py makemigrations –empty <yourapp> In Django 1.8+, you can provide a name: … Read more

rake db:schema:load vs. migrations

Migrations provide forward and backward step changes to the database. In a production environment, incremental changes must be made to the database during deploys: migrations provide this functionality with a rollback failsafe. If you run rake db:schema:load on a production server, you’ll end up deleting all your production data. This is a dangerous habit to … Read more