Migrate03to04: migrate.sh

File migrate.sh, 1.0 kB (added by ged, 5 years ago)

Migration script from statement-based (using has_field) syntax to attribute-based syntax.

Line 
1sed -i "s/belongs_to(['\"]\(\w\+\)['\"], through=\([^,]\+\), via=/\1 = AssociationProxy(\2, /" $1
2sed -i "s/belongs_to(['\"]\(\w\+\)['\"], of_kind=/\1 = ManyToOne(/" $1
3sed -i "s/has_many(['\"]\(\w\+\)['\"], through=\([^,]\+\), via=/\1 = AssociationProxy(\2, /" $1
4sed -i "s/has_many(['\"]\(\w\+\)['\"], of_kind=/\1 = OneToMany(/" $1
5sed -i "s/has_one(['\"]\(\w\+\)['\"], through=\([^,]\+\), via=/\1 = AssociationProxy(\2, /" $1
6sed -i "s/has_one(['\"]\(\w\+\)['\"], of_kind=/\1 = OneToOne(/" $1
7sed -i "s/has_and_belongs_to_many(['\"]\(\w\+\)['\"], through=\([^,]\+\), via=/\1 = AssociationProxy(\2, /" $1
8sed -i "s/has_and_belongs_to_many(['\"]\(\w\+\)['\"], of_kind=/\1 = ManyToMany(/" $1
9sed -i "s/has_field(['\"]\(\w\+\)['\"], through=\(['\"a-zA-Z0-9_]\+\), attribute=\(['\"a-zA-Z0-9_]\+\)/\1 = AssociationProxy(\2, \3/" $1
10sed -i "s/has_field(\(['\"]\)\(\w\+\)['\"], through=\(['\"a-zA-Z0-9_]\+\)/\1 = AssociationProxy(\3, \1\2\1/" $1
11sed -i "s/has_field(['\"]\(\w\+\)['\"], /\1 = Field(/" $1
12