Migration

Code Generation starts with database design.

circle-exclamation

Best practice in Yee is not to manually create your database, but to use code to do it. This allows collaboration in large team possible where everybody may have their own version of local database in development environment.

Migration also is a key player in modular architecture, where module can be install and upgrade easily by super admin. In this case, migration code either sit in insallDb function at module like SampleModule.phpor; sit in the upgrades folder.

Create Table

circle-info

Table column naming is use to instruct Yee on how to generate code for models, controllers and views. Hence, naming convention for table columns is strict and must be follow by all developers. Check Fundemental Concept for more detail.

$migration->createTable('sample', array(
			'id' => 'pk',
			'code' => 'string NOT NULL',
			'sample_group_id' => 'integer NULL',
			'sample_zone_code' => 'string NULL',
			'title_en' => 'string NOT NULL',
			'title_ms' => 'string NOT NULL',
			'title_zh' => 'string NOT NULL',
			'text_short_description_en' => 'string NOT NULL',
			'text_short_description_ms' => 'string NOT NULL',
			'text_short_description_zh' => 'string NOT NULL',
			'html_content_en' => 'longtext NULL',
			'html_content_ms' => 'longtext NULL',
			'html_content_zh' => 'longtext NULL',
			'image_main' => 'string NULL',
			'file_backup' => 'string NULL',
			'price_main' => 'decimal(10,0) NULL DEFAULT 0',
			'gender' => 'string NULL',
			'age' => 'integer NULL',
			'csv_keyword' => 'mediumtext NULL',
			'ordering' => 'double NOT NULL DEFAULT 1',
			'date_posted' => 'integer NOT NULL',
			'is_active' => 'boolean NOT NULL DEFAULT 1',
			'is_public' => 'boolean NOT NULL DEFAULT 1',
			'is_member' => 'boolean NOT NULL DEFAULT 1',
			'is_admin' => 'boolean NOT NULL DEFAULT 1',
			'date_added' => 'integer NOT NULL',
			'date_modified' => 'integer NOT NULL',
		));

Alter Table

Create Index

Two type of index here, the simple one:

and the combination (combine more than 1 table fields as an unique index, mostly appear in many-to-many table):

Create Foreign Key

Execute Raw SQL

This is handy when you need to bulk update your existing data in database.

Create Meta

Create Setting

Create Embed

circle-info

Remember: always prefix your embed with module code (e.g. boilerplateStart-,sample-) or realm / context code (e.g. cpanel-)

Create Service

Create Access Role

Last updated