So we have the all reservations page working pretty much the way we want it to.
Now we want to do the new reservations page.
And as I suggested earlier, one of the things we have to do is we need to have some means of determining
whether a reservation is new or one we already know about.
And that means we need to add a column to the database and we already know how to do that.
So let's go do it.
I'll go over to my I.D. and I will open my terminal window and clear it and I'll make sure I'm in the
correct directory.
I am.
So let's create a new migration.
So to generate fees add processed, which is what I'll call the column two reservations table, and
that creates two new migrations.
So let's open those up there in our migrations folder, which is right here, and they'll be at the
bottom.
So let's do the down migration first.
And this will, of course, run when we want to reverse migration.
And that's just as simple as drop column and the name of the table reservations and the name of the
column, which I'm going to call processed.
So that's done.
Now, let's open the up migration.
And this is add column.
And again, the table reservations, the column name which will be processed.
The column type will be integer
and then in curly brackets, I'll give it a default of zero.
So now when someone enters a reservation, we don't need to do anything, we don't need to change any
code because it has a default value of zero, and any reservation that has a value of zero in the process
column will by default be a new reservation.
And we should be able to run this migration so to migrate.
And there it is, so we have it all at it now that that's added, we need to actually make the necessary
database queries.
So let's go back to our postgrads.
And as you might guess, this is pretty simple.
I'm just going to copy this existing one for all migration's.
Paste it below it, change its name to all reserve to new reservations.
I think I called it all migration's a moment ago, but you knew what I meant.
So this will be new reservations and I'll call it all new reservations just to make it really clear
what this function does.
And of course, I just need to add a weird clause where processed.
Equals zero, and let's actually change this one as well.
We will add up here just after our updated at will, put our protest and down here, that's after updated
at which is right here.
We'll duplicate this and add processed, which doesn't exist yet, but we'll add it to the model in
a minute.
So let's open our models.
And find reservation.
Which is right here and let's add processed, which will be of type int.
OK, so hopefully that fixed our problem in our postgrads and it did good.
The last thing we need to do here is to copy this entire function, which is right here, all new reservations,
and add that to our test repo, which is under internal repository.
Test repo pay and get rid of all the things we don't want, which is all of this stuff, plus the context,
change its receiver to the correct type and then add this to our repository.
So open the repository, paste it in and do I guess I didn't copy the right thing.
Copy paste there.
So that should compile.
But first, let's add that to our handlers.
Let's take advantage of the one we just created and added to our handlers.
So handlers and we're looking for all new admin, new reservations.
There it is.
So what I can do here is copy all of this and modify it just to save some time.
OK, and I missed Mr. Line.
Paste, I copy and paste skills leave a little to be desired today, I apologize for that.
And we're going to add that to data data and changes to all new reservations.
All right, let's give these things some comments, shows all new reservations in admin tool.
And this one needs a comment.
Shows all reservations in admin tool.
I think I have comments for everything else, looks like I know I must show log.
I just like to keep these things properly formatted.
Shows the login screen.
All right.
So let's run our application.
It compiles perfect, this should still show the same thing because we haven't changed our template,
but it works good.
Let's go back and fix our template and what we can do is copy and paste and then make modifications
as necessary.
So under our templates, first of all, let's go to our all reservations page and copy this script part
for the bottom and then open our new reservations page and paste that in.
And we'll call the table new regs and go back to our old reservations page and copy everything in here.
And back to our new reservations page and paste it in here.
No time to get rid of those carbon tags, I guess, there and we have ID last name.
Everything is the same.
We'll change this to new in the link so we know where we're coming from.
So in the other one, we had admin reservations, all ID, now we'll have admin reservations, new ID,
just so we know where we're coming from.
And that will become apparent why I'm doing that in a lecture or to everything else.
You know, I guess I missed the here the CSFs.
We need that and we'll put that here.
And I should now at this point be able to reload that page and see a table.
Let's find out.
OK, not quite right.
What did I miss?
Oh, yes, I need to change the ID to New Redd's.
That looks better, perfect, so now we have our new reservations display and they're all new because
I've never processed any of them and I just added that column.
So by default, they all have zero for processed.
And if we change something in the database, which we'll do when we get to actually modifying reservations,
which is the next lecture or two, then we should be good to go.
So we have new reservations.
We have all reservations which currently show the same information because all reservations are new
reservations.
But I think we're pretty much ready to go.
So in the next lecture, we'll start working on clicking on a link to a reservation and displaying it
and then processing it as required.
And we'll take care of that in the next lecture or two.