-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend user table and add photo table
- Loading branch information
Showing
6 changed files
with
341 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
using System; | ||
using Microsoft.EntityFrameworkCore.Metadata; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
namespace Friendster.Migrations | ||
{ | ||
public partial class ExtendUserClass : Migration | ||
{ | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.AddColumn<DateTime>( | ||
name: "BirthDate", | ||
table: "Users", | ||
nullable: false, | ||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); | ||
|
||
migrationBuilder.AddColumn<string>( | ||
name: "City", | ||
table: "Users", | ||
nullable: true); | ||
|
||
migrationBuilder.AddColumn<string>( | ||
name: "Country", | ||
table: "Users", | ||
nullable: true); | ||
|
||
migrationBuilder.AddColumn<DateTime>( | ||
name: "DateCreated", | ||
table: "Users", | ||
nullable: false, | ||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); | ||
|
||
migrationBuilder.AddColumn<int>( | ||
name: "Gender", | ||
table: "Users", | ||
nullable: false, | ||
defaultValue: 0); | ||
|
||
migrationBuilder.AddColumn<string>( | ||
name: "Interests", | ||
table: "Users", | ||
nullable: true); | ||
|
||
migrationBuilder.AddColumn<string>( | ||
name: "Introduction", | ||
table: "Users", | ||
nullable: true); | ||
|
||
migrationBuilder.AddColumn<string>( | ||
name: "KnownAs", | ||
table: "Users", | ||
nullable: true); | ||
|
||
migrationBuilder.AddColumn<DateTime>( | ||
name: "LastActive", | ||
table: "Users", | ||
nullable: false, | ||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); | ||
|
||
migrationBuilder.AddColumn<int>( | ||
name: "LookingFor", | ||
table: "Users", | ||
nullable: false, | ||
defaultValue: 0); | ||
|
||
migrationBuilder.CreateTable( | ||
name: "Photos", | ||
columns: table => new | ||
{ | ||
Id = table.Column<int>(nullable: false) | ||
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), | ||
Url = table.Column<string>(nullable: true), | ||
Description = table.Column<string>(nullable: true), | ||
DateAdded = table.Column<DateTime>(nullable: false), | ||
IsMain = table.Column<bool>(nullable: false), | ||
UserId = table.Column<int>(nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_Photos", x => x.Id); | ||
table.ForeignKey( | ||
name: "FK_Photos_Users_UserId", | ||
column: x => x.UserId, | ||
principalTable: "Users", | ||
principalColumn: "Id", | ||
onDelete: ReferentialAction.Cascade); | ||
}); | ||
|
||
migrationBuilder.CreateIndex( | ||
name: "IX_Photos_UserId", | ||
table: "Photos", | ||
column: "UserId"); | ||
} | ||
|
||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropTable( | ||
name: "Photos"); | ||
|
||
migrationBuilder.DropColumn( | ||
name: "BirthDate", | ||
table: "Users"); | ||
|
||
migrationBuilder.DropColumn( | ||
name: "City", | ||
table: "Users"); | ||
|
||
migrationBuilder.DropColumn( | ||
name: "Country", | ||
table: "Users"); | ||
|
||
migrationBuilder.DropColumn( | ||
name: "DateCreated", | ||
table: "Users"); | ||
|
||
migrationBuilder.DropColumn( | ||
name: "Gender", | ||
table: "Users"); | ||
|
||
migrationBuilder.DropColumn( | ||
name: "Interests", | ||
table: "Users"); | ||
|
||
migrationBuilder.DropColumn( | ||
name: "Introduction", | ||
table: "Users"); | ||
|
||
migrationBuilder.DropColumn( | ||
name: "KnownAs", | ||
table: "Users"); | ||
|
||
migrationBuilder.DropColumn( | ||
name: "LastActive", | ||
table: "Users"); | ||
|
||
migrationBuilder.DropColumn( | ||
name: "LookingFor", | ||
table: "Users"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Friendster.Models | ||
{ | ||
public class Photo | ||
{ | ||
public int Id { get; set; } | ||
public string Url { get; set; } | ||
public string Description { get; set; } | ||
public DateTime DateAdded { get; set; } | ||
public bool IsMain { get; set; } | ||
|
||
public User User { get; set; } | ||
public int UserId { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,31 @@ | ||
namespace Friendster.Models | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Friendster.Models | ||
{ | ||
public class User | ||
{ | ||
public int Id { get; set; } | ||
public string Username { get; set; } | ||
public byte[] PasswordHash { get; set; } | ||
public byte[] PasswordSalt { get; set; } | ||
public Gender Gender { get; set; } | ||
public DateTime BirthDate { get; set; } | ||
public string KnownAs { get; set; } | ||
public DateTime DateCreated { get; set; } | ||
public DateTime LastActive { get; set; } | ||
public string Introduction { get; set; } | ||
public Gender LookingFor { get; set; } | ||
public string Interests { get; set; } | ||
public string City { get; set; } | ||
public string Country { get; set; } | ||
public ICollection<Photo> Photos { get; set; } | ||
} | ||
|
||
public enum Gender | ||
{ | ||
Male, | ||
Female, | ||
Both | ||
} | ||
} |