alpas v0.15.0 Release Notes
Release Date: 2020-02-18 // about 4 years ago-
๐ This release brings even more exciting features and improvements to Alpas. Here are the highlights:
๐ฑ ๐ New Features
โ๏ธ Resourceful Routes
You can create a resourceful routes for all the CRUD operations by using
resources()
method:
resources<PostController>("posts").name("posts")
โ๏ธ Auto Port Selection
๐ In dev mode Alpas automatically selects the next port if the selected port is in use already. Docs.
โ๏ธ Ozone Extensions
โก๏ธ Few useful methods and conventions are added in Ozone such as
findOrCreate(attrs)
,findOne(attrs)
,findMany()
,update(attrs)
,reference()
etc. Docs.โ๏ธ Column Binding Conventions
โก๏ธ Also added are four new column bindings -
createdAt()
,updatedAt()
,increments()
,bigIncrements()
.
๐ Docs.This means instead of this:
val id by bigInt("id").autoIncrement().unsigned().primaryKey().bindTo{ it.id }val createdAt by timestamp("created\_at").nullable().useCurrent().bindTo { it.createdAt }val updatedAt by timestamp("updated\_at").nullable().useCurrent().bindTo { it.updatedAt }
You can do this:
val id by bigIncrements()val createdAt by createdAt()val updatedAt by updatedAt()
โ๏ธ Routes reloading without re-running the app
๐ In dev mode, routes are now reloaded without restarting the app. For performance reason this is disabled in the prod mode.
โ๏ธ Run migrations using a name property
This allows to run migrations even from a fat jar. Very helpful in production.
โ๏ธ Added basic table modification support
You can now
addColumn()
anddropColumn()
โ๏ธ Reference Constraint
You can now add a reference constraint on a column:
val userId by long("user\_id").belongsTo(Users) { it.user }.unsigned().reference { onDeleteCascade() }
๐ฑ ๐ Improvements
โก๏ธ ๐ Assets handling is more optimized.
๐ ๐ You can seed a database with database refresh by using
--seed
flag.๐ฑ ๐ Improved strong typing while overriding an entity's properties in an entity factory.
val user = from(UserFactory) { it.name to "Jane M. Doe" it.email to "[email protected]"}
๐ฑ ๐ Breaking Changes
๐ There are few but significant breaking changes in this release:
๐คฆ๐ฝโโ๏ธ
Entity
has been renamed toOzoneEntity
andMigratingTable
has been renamed toOzoneTable
:// Before: interface User : Entity\<User\>// Now:interface User : OzoneEntity\<User\> { // ...// Before: companion object : Entity.Factory\<User\>// Now:companion object : OzoneEntity.Of\<User\>() }// Before: object Users : MigratingTable\<User\>// Now:object Users : OzoneTable\<User\>("users") { // ...}
๐คฆ๐ฝโโ๏ธ
EntityFactory
now takes two parameters instead of one:// Before: class UserFactory() : EntityFactory\<User\>()// Now:class UserFactory() : EntityFactory\<User, Users\>() { // ...}
๐คฆ๐ฝโโ๏ธ Methods Renamed:
onlyParams()
method has been renamed toparams()
paramAsString()
method is nowstringParam()
paramAsInt()
is nowintParam()
paramAsLong()
is nowlongParam()
paramAsBool()
is nowboolParam()