Skip to content

Instantly share code, notes, and snippets.

@ismail1432
Last active February 1, 2022 08:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ismail1432/10b7ed0b0172295194ba052d0eaea9a2 to your computer and use it in GitHub Desktop.
Save ismail1432/10b7ed0b0172295194ba052d0eaea9a2 to your computer and use it in GitHub Desktop.

Remove a column

We want to remove the column name from table user

current version, V 1.0

class User
{
  /**
   * @ORM\Column(type="string", nullable=false)
   */
  private string $name; 
  public setName(string $name){};
  public getName(): string {};
}

V 1.1

💡 Remove ALL references to the column (property and accessors)

💡 Make the column nullable

- /**
-  * @ORM\Column(type="string", nullable=false)
-  */
-  private string $name; 
-  public setName(string $name){};
-  public getName(): string {};

+ ALTER TABLE user ALTER name DROP NOT NULL

V 1.2

💡 Remove the column

+ ALTER TABLE user DROP name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment